repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
OpenHumans/open-humans-api
ohapi/utils_fs.py
guess_tags
def guess_tags(filename): """ Function to get potential tags for files using the file names. :param filename: This field is the name of file. """ tags = [] stripped_filename = strip_zip_suffix(filename) if stripped_filename.endswith('.vcf'): tags.append('vcf') if stripped_filena...
python
def guess_tags(filename): """ Function to get potential tags for files using the file names. :param filename: This field is the name of file. """ tags = [] stripped_filename = strip_zip_suffix(filename) if stripped_filename.endswith('.vcf'): tags.append('vcf') if stripped_filena...
[ "def", "guess_tags", "(", "filename", ")", ":", "tags", "=", "[", "]", "stripped_filename", "=", "strip_zip_suffix", "(", "filename", ")", "if", "stripped_filename", ".", "endswith", "(", "'.vcf'", ")", ":", "tags", ".", "append", "(", "'vcf'", ")", "if", ...
Function to get potential tags for files using the file names. :param filename: This field is the name of file.
[ "Function", "to", "get", "potential", "tags", "for", "files", "using", "the", "file", "names", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L33-L47
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
characterize_local_files
def characterize_local_files(filedir, max_bytes=MAX_FILE_DEFAULT): """ Collate local file info as preperation for Open Humans upload. Note: Files with filesize > max_bytes are not included in returned info. :param filedir: This field is target directory to get files from. :param max_bytes: This fi...
python
def characterize_local_files(filedir, max_bytes=MAX_FILE_DEFAULT): """ Collate local file info as preperation for Open Humans upload. Note: Files with filesize > max_bytes are not included in returned info. :param filedir: This field is target directory to get files from. :param max_bytes: This fi...
[ "def", "characterize_local_files", "(", "filedir", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "file_data", "=", "{", "}", "logging", ".", "info", "(", "'Characterizing files in {}'", ".", "format", "(", "filedir", ")", ")", "for", "filename", "in", "...
Collate local file info as preperation for Open Humans upload. Note: Files with filesize > max_bytes are not included in returned info. :param filedir: This field is target directory to get files from. :param max_bytes: This field is the maximum file size to consider. Its default value is 128m.
[ "Collate", "local", "file", "info", "as", "preperation", "for", "Open", "Humans", "upload", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L50-L79
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
validate_metadata
def validate_metadata(target_dir, metadata): """ Check that the files listed in metadata exactly match files in target dir. :param target_dir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to be matched. """ if not os.p...
python
def validate_metadata(target_dir, metadata): """ Check that the files listed in metadata exactly match files in target dir. :param target_dir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to be matched. """ if not os.p...
[ "def", "validate_metadata", "(", "target_dir", ",", "metadata", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "target_dir", ")", ":", "print", "(", "\"Error: \"", "+", "target_dir", "+", "\" is not a directory\"", ")", "return", "False", "file...
Check that the files listed in metadata exactly match files in target dir. :param target_dir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to be matched.
[ "Check", "that", "the", "files", "listed", "in", "metadata", "exactly", "match", "files", "in", "target", "dir", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L82-L104
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
load_metadata_csv_single_user
def load_metadata_csv_single_user(csv_in, header, tags_idx): """ Return the metadata as requested for a single user. :param csv_in: This field is the csv file to return metadata from. :param header: This field contains the headers in the csv file :param tags_idx: This field contains the index of th...
python
def load_metadata_csv_single_user(csv_in, header, tags_idx): """ Return the metadata as requested for a single user. :param csv_in: This field is the csv file to return metadata from. :param header: This field contains the headers in the csv file :param tags_idx: This field contains the index of th...
[ "def", "load_metadata_csv_single_user", "(", "csv_in", ",", "header", ",", "tags_idx", ")", ":", "metadata", "=", "{", "}", "n_headers", "=", "len", "(", "header", ")", "for", "index", ",", "row", "in", "enumerate", "(", "csv_in", ",", "2", ")", ":", "...
Return the metadata as requested for a single user. :param csv_in: This field is the csv file to return metadata from. :param header: This field contains the headers in the csv file :param tags_idx: This field contains the index of the tags in the csv file.
[ "Return", "the", "metadata", "as", "requested", "for", "a", "single", "user", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L107-L136
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
load_metadata_csv
def load_metadata_csv(input_filepath): """ Return dict of metadata. Format is either dict (filenames are keys) or dict-of-dicts (project member IDs as top level keys, then filenames as keys). :param input_filepath: This field is the filepath of the csv file. """ with open(input_filepath) a...
python
def load_metadata_csv(input_filepath): """ Return dict of metadata. Format is either dict (filenames are keys) or dict-of-dicts (project member IDs as top level keys, then filenames as keys). :param input_filepath: This field is the filepath of the csv file. """ with open(input_filepath) a...
[ "def", "load_metadata_csv", "(", "input_filepath", ")", ":", "with", "open", "(", "input_filepath", ")", "as", "f", ":", "csv_in", "=", "csv", ".", "reader", "(", "f", ")", "header", "=", "next", "(", "csv_in", ")", "if", "'tags'", "in", "header", ":",...
Return dict of metadata. Format is either dict (filenames are keys) or dict-of-dicts (project member IDs as top level keys, then filenames as keys). :param input_filepath: This field is the filepath of the csv file.
[ "Return", "dict", "of", "metadata", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L176-L206
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
validate_date
def validate_date(date, project_member_id, filename): """ Check if date is in ISO 8601 format. :param date: This field is the date to be checked. :param project_member_id: This field is the project_member_id corresponding to the date provided. :param filename: This field is the filename cor...
python
def validate_date(date, project_member_id, filename): """ Check if date is in ISO 8601 format. :param date: This field is the date to be checked. :param project_member_id: This field is the project_member_id corresponding to the date provided. :param filename: This field is the filename cor...
[ "def", "validate_date", "(", "date", ",", "project_member_id", ",", "filename", ")", ":", "try", ":", "arrow", ".", "get", "(", "date", ")", "except", "Exception", ":", "return", "False", "return", "True" ]
Check if date is in ISO 8601 format. :param date: This field is the date to be checked. :param project_member_id: This field is the project_member_id corresponding to the date provided. :param filename: This field is the filename corresponding to the date provided.
[ "Check", "if", "date", "is", "in", "ISO", "8601", "format", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L218-L232
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
is_single_file_metadata_valid
def is_single_file_metadata_valid(file_metadata, project_member_id, filename): """ Check if metadata fields like project member id, description, tags, md5 and creation date are valid for a single file. :param file_metadata: This field is metadata of file. :param project_member_id: This field is the...
python
def is_single_file_metadata_valid(file_metadata, project_member_id, filename): """ Check if metadata fields like project member id, description, tags, md5 and creation date are valid for a single file. :param file_metadata: This field is metadata of file. :param project_member_id: This field is the...
[ "def", "is_single_file_metadata_valid", "(", "file_metadata", ",", "project_member_id", ",", "filename", ")", ":", "if", "project_member_id", "is", "not", "None", ":", "if", "not", "project_member_id", ".", "isdigit", "(", ")", "or", "len", "(", "project_member_id...
Check if metadata fields like project member id, description, tags, md5 and creation date are valid for a single file. :param file_metadata: This field is metadata of file. :param project_member_id: This field is the project member id corresponding to the file metadata provided. :param filename...
[ "Check", "if", "metadata", "fields", "like", "project", "member", "id", "description", "tags", "md5", "and", "creation", "date", "are", "valid", "for", "a", "single", "file", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L235-L292
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
review_metadata_csv_single_user
def review_metadata_csv_single_user(filedir, metadata, csv_in, n_headers): """ Check validity of metadata for single user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_c...
python
def review_metadata_csv_single_user(filedir, metadata, csv_in, n_headers): """ Check validity of metadata for single user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_c...
[ "def", "review_metadata_csv_single_user", "(", "filedir", ",", "metadata", ",", "csv_in", ",", "n_headers", ")", ":", "try", ":", "if", "not", "validate_metadata", "(", "filedir", ",", "metadata", ")", ":", "return", "False", "for", "filename", ",", "file_meta...
Check validity of metadata for single user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_csv function. :param csv_in: This field returns a reader object which iterates over ...
[ "Check", "validity", "of", "metadata", "for", "single", "user", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L295-L315
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
validate_subfolders
def validate_subfolders(filedir, metadata): """ Check that all folders in the given directory have a corresponding entry in the metadata file, and vice versa. :param filedir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to...
python
def validate_subfolders(filedir, metadata): """ Check that all folders in the given directory have a corresponding entry in the metadata file, and vice versa. :param filedir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to...
[ "def", "validate_subfolders", "(", "filedir", ",", "metadata", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "filedir", ")", ":", "print", "(", "\"Error: \"", "+", "filedir", "+", "\" is not a directory\"", ")", "return", "False", "subfolders"...
Check that all folders in the given directory have a corresponding entry in the metadata file, and vice versa. :param filedir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to be matched.
[ "Check", "that", "all", "folders", "in", "the", "given", "directory", "have", "a", "corresponding", "entry", "in", "the", "metadata", "file", "and", "vice", "versa", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L318-L341
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
review_metadata_csv_multi_user
def review_metadata_csv_multi_user(filedir, metadata, csv_in, n_headers): """ Check validity of metadata for multi user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_csv...
python
def review_metadata_csv_multi_user(filedir, metadata, csv_in, n_headers): """ Check validity of metadata for multi user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_csv...
[ "def", "review_metadata_csv_multi_user", "(", "filedir", ",", "metadata", ",", "csv_in", ",", "n_headers", ")", ":", "try", ":", "if", "not", "validate_subfolders", "(", "filedir", ",", "metadata", ")", ":", "return", "False", "for", "project_member_id", ",", ...
Check validity of metadata for multi user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_csv function. :param csv_in: This field returns a reader object which iterates over t...
[ "Check", "validity", "of", "metadata", "for", "multi", "user", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L344-L371
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
review_metadata_csv
def review_metadata_csv(filedir, input_filepath): """ Check validity of metadata fields. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param max_bytes: This field is the maximum fi...
python
def review_metadata_csv(filedir, input_filepath): """ Check validity of metadata fields. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param max_bytes: This field is the maximum fi...
[ "def", "review_metadata_csv", "(", "filedir", ",", "input_filepath", ")", ":", "try", ":", "metadata", "=", "load_metadata_csv", "(", "input_filepath", ")", "except", "ValueError", "as", "e", ":", "print_error", "(", "e", ")", "return", "False", "with", "open"...
Check validity of metadata fields. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param max_bytes: This field is the maximum file size to consider. Its default value is 128m.
[ "Check", "validity", "of", "metadata", "fields", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L374-L401
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
write_metadata_to_filestream
def write_metadata_to_filestream(filedir, filestream, max_bytes=MAX_FILE_DEFAULT): """ Make metadata file for all files in a directory(helper function) :param filedir: This field is the filepath of the directory whose csv has to be made. :param filestream: This ...
python
def write_metadata_to_filestream(filedir, filestream, max_bytes=MAX_FILE_DEFAULT): """ Make metadata file for all files in a directory(helper function) :param filedir: This field is the filepath of the directory whose csv has to be made. :param filestream: This ...
[ "def", "write_metadata_to_filestream", "(", "filedir", ",", "filestream", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "csv_out", "=", "csv", ".", "writer", "(", "filestream", ")", "subdirs", "=", "[", "os", ".", "path", ".", "join", "(", "filedir", ...
Make metadata file for all files in a directory(helper function) :param filedir: This field is the filepath of the directory whose csv has to be made. :param filestream: This field is a stream for writing to the csv. :param max_bytes: This field is the maximum file size to consider. Its def...
[ "Make", "metadata", "file", "for", "all", "files", "in", "a", "directory", "(", "helper", "function", ")" ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L404-L452
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
mk_metadata_csv
def mk_metadata_csv(filedir, outputfilepath, max_bytes=MAX_FILE_DEFAULT): """ Make metadata file for all files in a directory. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param m...
python
def mk_metadata_csv(filedir, outputfilepath, max_bytes=MAX_FILE_DEFAULT): """ Make metadata file for all files in a directory. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param m...
[ "def", "mk_metadata_csv", "(", "filedir", ",", "outputfilepath", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "with", "open", "(", "outputfilepath", ",", "'w'", ")", "as", "filestream", ":", "write_metadata_to_filestream", "(", "filedir", ",", "filestream"...
Make metadata file for all files in a directory. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param max_bytes: This field is the maximum file size to consider. Its default value i...
[ "Make", "metadata", "file", "for", "all", "files", "in", "a", "directory", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L455-L466
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
download_file
def download_file(download_url, target_filepath, max_bytes=MAX_FILE_DEFAULT): """ Download a file. :param download_url: This field is the url from which data will be downloaded. :param target_filepath: This field is the path of the file where data will be downloaded. :param max_byte...
python
def download_file(download_url, target_filepath, max_bytes=MAX_FILE_DEFAULT): """ Download a file. :param download_url: This field is the url from which data will be downloaded. :param target_filepath: This field is the path of the file where data will be downloaded. :param max_byte...
[ "def", "download_file", "(", "download_url", ",", "target_filepath", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "response", "=", "requests", ".", "get", "(", "download_url", ",", "stream", "=", "True", ")", "size", "=", "int", "(", "response", ".",...
Download a file. :param download_url: This field is the url from which data will be downloaded. :param target_filepath: This field is the path of the file where data will be downloaded. :param max_bytes: This field is the maximum file size to download. Its default value is 128m.
[ "Download", "a", "file", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L469-L506
train
OpenHumans/open-humans-api
ohapi/utils_fs.py
read_id_list
def read_id_list(filepath): """ Get project member id from a file. :param filepath: This field is the path of file to read. """ if not filepath: return None id_list = [] with open(filepath) as f: for line in f: line = line.rstrip() if not re.match('^[...
python
def read_id_list(filepath): """ Get project member id from a file. :param filepath: This field is the path of file to read. """ if not filepath: return None id_list = [] with open(filepath) as f: for line in f: line = line.rstrip() if not re.match('^[...
[ "def", "read_id_list", "(", "filepath", ")", ":", "if", "not", "filepath", ":", "return", "None", "id_list", "=", "[", "]", "with", "open", "(", "filepath", ")", "as", "f", ":", "for", "line", "in", "f", ":", "line", "=", "line", ".", "rstrip", "("...
Get project member id from a file. :param filepath: This field is the path of file to read.
[ "Get", "project", "member", "id", "from", "a", "file", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L509-L526
train
OpenHumans/open-humans-api
ohapi/command_line.py
set_log_level
def set_log_level(debug, verbose): """ Function for setting the logging level. :param debug: This boolean field is the logging level. :param verbose: This boolean field is the logging level. """ if debug: logging.basicConfig(level=logging.DEBUG) elif verbose: logging.basicCo...
python
def set_log_level(debug, verbose): """ Function for setting the logging level. :param debug: This boolean field is the logging level. :param verbose: This boolean field is the logging level. """ if debug: logging.basicConfig(level=logging.DEBUG) elif verbose: logging.basicCo...
[ "def", "set_log_level", "(", "debug", ",", "verbose", ")", ":", "if", "debug", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "DEBUG", ")", "elif", "verbose", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", ...
Function for setting the logging level. :param debug: This boolean field is the logging level. :param verbose: This boolean field is the logging level.
[ "Function", "for", "setting", "the", "logging", "level", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L24-L34
train
OpenHumans/open-humans-api
ohapi/command_line.py
download_cli
def download_cli(directory, master_token=None, member=None, access_token=None, source=None, project_data=False, max_size='128m', verbose=False, debug=False, memberlist=None, excludelist=None, id_filename=False): """ Command line function for downloading data fr...
python
def download_cli(directory, master_token=None, member=None, access_token=None, source=None, project_data=False, max_size='128m', verbose=False, debug=False, memberlist=None, excludelist=None, id_filename=False): """ Command line function for downloading data fr...
[ "def", "download_cli", "(", "directory", ",", "master_token", "=", "None", ",", "member", "=", "None", ",", "access_token", "=", "None", ",", "source", "=", "None", ",", "project_data", "=", "False", ",", "max_size", "=", "'128m'", ",", "verbose", "=", "...
Command line function for downloading data from project members to the target directory. For more information visit :func:`download<ohapi.command_line.download>`.
[ "Command", "line", "function", "for", "downloading", "data", "from", "project", "members", "to", "the", "target", "directory", ".", "For", "more", "information", "visit", ":", "func", ":", "download<ohapi", ".", "command_line", ".", "download", ">", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L56-L67
train
OpenHumans/open-humans-api
ohapi/command_line.py
download
def download(directory, master_token=None, member=None, access_token=None, source=None, project_data=False, max_size='128m', verbose=False, debug=False, memberlist=None, excludelist=None, id_filename=False): """ Download data from project members to the target directory. ...
python
def download(directory, master_token=None, member=None, access_token=None, source=None, project_data=False, max_size='128m', verbose=False, debug=False, memberlist=None, excludelist=None, id_filename=False): """ Download data from project members to the target directory. ...
[ "def", "download", "(", "directory", ",", "master_token", "=", "None", ",", "member", "=", "None", ",", "access_token", "=", "None", ",", "source", "=", "None", ",", "project_data", "=", "False", ",", "max_size", "=", "'128m'", ",", "verbose", "=", "Fals...
Download data from project members to the target directory. Unless this is a member-specific download, directories will be created for each project member ID. Also, unless a source is specified, all shared sources are downloaded and data is sorted into subdirectories according to source. Projects ...
[ "Download", "data", "from", "project", "members", "to", "the", "target", "directory", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L70-L158
train
OpenHumans/open-humans-api
ohapi/command_line.py
download_metadata_cli
def download_metadata_cli(master_token, output_csv, verbose=False, debug=False): """ Command line function for downloading metadata. For more information visit :func:`download_metadata<ohapi.command_line.download_metadata>`. """ return download_metadata(master_token, ou...
python
def download_metadata_cli(master_token, output_csv, verbose=False, debug=False): """ Command line function for downloading metadata. For more information visit :func:`download_metadata<ohapi.command_line.download_metadata>`. """ return download_metadata(master_token, ou...
[ "def", "download_metadata_cli", "(", "master_token", ",", "output_csv", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":", "return", "download_metadata", "(", "master_token", ",", "output_csv", ",", "verbose", ",", "debug", ")" ]
Command line function for downloading metadata. For more information visit :func:`download_metadata<ohapi.command_line.download_metadata>`.
[ "Command", "line", "function", "for", "downloading", "metadata", ".", "For", "more", "information", "visit", ":", "func", ":", "download_metadata<ohapi", ".", "command_line", ".", "download_metadata", ">", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L168-L175
train
OpenHumans/open-humans-api
ohapi/command_line.py
download_metadata
def download_metadata(master_token, output_csv, verbose=False, debug=False): """ Output CSV with metadata for a project's downloadable files in Open Humans. :param master_token: This field is the master access token for the project. :param output_csv: This field is the target csv file to which metadata...
python
def download_metadata(master_token, output_csv, verbose=False, debug=False): """ Output CSV with metadata for a project's downloadable files in Open Humans. :param master_token: This field is the master access token for the project. :param output_csv: This field is the target csv file to which metadata...
[ "def", "download_metadata", "(", "master_token", ",", "output_csv", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":", "set_log_level", "(", "debug", ",", "verbose", ")", "project", "=", "OHProject", "(", "master_access_token", "=", "master_to...
Output CSV with metadata for a project's downloadable files in Open Humans. :param master_token: This field is the master access token for the project. :param output_csv: This field is the target csv file to which metadata is written. :param verbose: This boolean field is the logging level. It's de...
[ "Output", "CSV", "with", "metadata", "for", "a", "project", "s", "downloadable", "files", "in", "Open", "Humans", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L178-L208
train
OpenHumans/open-humans-api
ohapi/command_line.py
upload_metadata_cli
def upload_metadata_cli(directory, create_csv='', review='', max_size='128m', verbose=False, debug=False): """ Command line function for drafting or reviewing metadata files. For more information visit :func:`upload_metadata<ohapi.command_line.upload_metadata>`. """ retur...
python
def upload_metadata_cli(directory, create_csv='', review='', max_size='128m', verbose=False, debug=False): """ Command line function for drafting or reviewing metadata files. For more information visit :func:`upload_metadata<ohapi.command_line.upload_metadata>`. """ retur...
[ "def", "upload_metadata_cli", "(", "directory", ",", "create_csv", "=", "''", ",", "review", "=", "''", ",", "max_size", "=", "'128m'", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":", "return", "upload_metadata", "(", "directory", ",", ...
Command line function for drafting or reviewing metadata files. For more information visit :func:`upload_metadata<ohapi.command_line.upload_metadata>`.
[ "Command", "line", "function", "for", "drafting", "or", "reviewing", "metadata", "files", ".", "For", "more", "information", "visit", ":", "func", ":", "upload_metadata<ohapi", ".", "command_line", ".", "upload_metadata", ">", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L219-L227
train
OpenHumans/open-humans-api
ohapi/command_line.py
upload_metadata
def upload_metadata(directory, create_csv='', review='', max_size='128m', verbose=False, debug=False): """ Draft or review metadata files for uploading files to Open Humans. The target directory should either represent files for a single member (no subdirectories), or contain a subdi...
python
def upload_metadata(directory, create_csv='', review='', max_size='128m', verbose=False, debug=False): """ Draft or review metadata files for uploading files to Open Humans. The target directory should either represent files for a single member (no subdirectories), or contain a subdi...
[ "def", "upload_metadata", "(", "directory", ",", "create_csv", "=", "''", ",", "review", "=", "''", ",", "max_size", "=", "'128m'", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":", "set_log_level", "(", "debug", ",", "verbose", ")", ...
Draft or review metadata files for uploading files to Open Humans. The target directory should either represent files for a single member (no subdirectories), or contain a subdirectory for each project member ID. :param directory: This field is the directory for which metadata has to be created. ...
[ "Draft", "or", "review", "metadata", "files", "for", "uploading", "files", "to", "Open", "Humans", ".", "The", "target", "directory", "should", "either", "represent", "files", "for", "a", "single", "member", "(", "no", "subdirectories", ")", "or", "contain", ...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L230-L261
train
OpenHumans/open-humans-api
ohapi/command_line.py
upload_cli
def upload_cli(directory, metadata_csv, master_token=None, member=None, access_token=None, safe=False, sync=False, max_size='128m', mode='default', verbose=False, debug=False): """ Command line function for uploading files to OH. For more information visit :func:`upload<oha...
python
def upload_cli(directory, metadata_csv, master_token=None, member=None, access_token=None, safe=False, sync=False, max_size='128m', mode='default', verbose=False, debug=False): """ Command line function for uploading files to OH. For more information visit :func:`upload<oha...
[ "def", "upload_cli", "(", "directory", ",", "metadata_csv", ",", "master_token", "=", "None", ",", "member", "=", "None", ",", "access_token", "=", "None", ",", "safe", "=", "False", ",", "sync", "=", "False", ",", "max_size", "=", "'128m'", ",", "mode",...
Command line function for uploading files to OH. For more information visit :func:`upload<ohapi.command_line.upload>`.
[ "Command", "line", "function", "for", "uploading", "files", "to", "OH", ".", "For", "more", "information", "visit", ":", "func", ":", "upload<ohapi", ".", "command_line", ".", "upload", ">", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L282-L292
train
OpenHumans/open-humans-api
ohapi/command_line.py
upload
def upload(directory, metadata_csv, master_token=None, member=None, access_token=None, safe=False, sync=False, max_size='128m', mode='default', verbose=False, debug=False): """ Upload files for the project to Open Humans member accounts. If using a master access token and not specifyi...
python
def upload(directory, metadata_csv, master_token=None, member=None, access_token=None, safe=False, sync=False, max_size='128m', mode='default', verbose=False, debug=False): """ Upload files for the project to Open Humans member accounts. If using a master access token and not specifyi...
[ "def", "upload", "(", "directory", ",", "metadata_csv", ",", "master_token", "=", "None", ",", "member", "=", "None", ",", "access_token", "=", "None", ",", "safe", "=", "False", ",", "sync", "=", "False", ",", "max_size", "=", "'128m'", ",", "mode", "...
Upload files for the project to Open Humans member accounts. If using a master access token and not specifying member ID: (1) Files should be organized in subdirectories according to project member ID, e.g.: main_directory/01234567/data.json main_directory/12345678/data.json main_...
[ "Upload", "files", "for", "the", "project", "to", "Open", "Humans", "member", "accounts", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L295-L411
train
OpenHumans/open-humans-api
ohapi/command_line.py
oauth_token_exchange_cli
def oauth_token_exchange_cli(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Command line function for obtaining the refresh token/code. For more information visit :func:`oauth2_token_exchange<oha...
python
def oauth_token_exchange_cli(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Command line function for obtaining the refresh token/code. For more information visit :func:`oauth2_token_exchange<oha...
[ "def", "oauth_token_exchange_cli", "(", "client_id", ",", "client_secret", ",", "redirect_uri", ",", "base_url", "=", "OH_BASE_URL", ",", "code", "=", "None", ",", "refresh_token", "=", "None", ")", ":", "print", "(", "oauth2_token_exchange", "(", "client_id", "...
Command line function for obtaining the refresh token/code. For more information visit :func:`oauth2_token_exchange<ohapi.api.oauth2_token_exchange>`.
[ "Command", "line", "function", "for", "obtaining", "the", "refresh", "token", "/", "code", ".", "For", "more", "information", "visit", ":", "func", ":", "oauth2_token_exchange<ohapi", ".", "api", ".", "oauth2_token_exchange", ">", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L427-L436
train
OpenHumans/open-humans-api
ohapi/command_line.py
oauth2_auth_url_cli
def oauth2_auth_url_cli(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Command line function for obtaining the Oauth2 url. For more information visit :func:`oauth2_auth_url<ohapi.api.oauth2_auth_url>`. """ result = oauth2_auth_url(redirect_uri, client_id, b...
python
def oauth2_auth_url_cli(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Command line function for obtaining the Oauth2 url. For more information visit :func:`oauth2_auth_url<ohapi.api.oauth2_auth_url>`. """ result = oauth2_auth_url(redirect_uri, client_id, b...
[ "def", "oauth2_auth_url_cli", "(", "redirect_uri", "=", "None", ",", "client_id", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ")", ":", "result", "=", "oauth2_auth_url", "(", "redirect_uri", ",", "client_id", ",", "base_url", ")", "print", "(", "'The req...
Command line function for obtaining the Oauth2 url. For more information visit :func:`oauth2_auth_url<ohapi.api.oauth2_auth_url>`.
[ "Command", "line", "function", "for", "obtaining", "the", "Oauth2", "url", ".", "For", "more", "information", "visit", ":", "func", ":", "oauth2_auth_url<ohapi", ".", "api", ".", "oauth2_auth_url", ">", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L444-L453
train
OpenHumans/open-humans-api
ohapi/command_line.py
message_cli
def message_cli(subject, message_body, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL, verbose=False, debug=False): """ Command line function for sending email to a single user or in bulk. For more information visit :func:`message<ohapi.api...
python
def message_cli(subject, message_body, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL, verbose=False, debug=False): """ Command line function for sending email to a single user or in bulk. For more information visit :func:`message<ohapi.api...
[ "def", "message_cli", "(", "subject", ",", "message_body", ",", "access_token", ",", "all_members", "=", "False", ",", "project_member_ids", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":",...
Command line function for sending email to a single user or in bulk. For more information visit :func:`message<ohapi.api.message>`.
[ "Command", "line", "function", "for", "sending", "email", "to", "a", "single", "user", "or", "in", "bulk", ".", "For", "more", "information", "visit", ":", "func", ":", "message<ohapi", ".", "api", ".", "message", ">", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L468-L480
train
OpenHumans/open-humans-api
ohapi/command_line.py
delete_cli
def delete_cli(access_token, project_member_id, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Command line function for deleting files. For more information visit :func:`delete_file<ohapi.api.delete_file>`. """ response = delete_file(access_token, p...
python
def delete_cli(access_token, project_member_id, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Command line function for deleting files. For more information visit :func:`delete_file<ohapi.api.delete_file>`. """ response = delete_file(access_token, p...
[ "def", "delete_cli", "(", "access_token", ",", "project_member_id", ",", "base_url", "=", "OH_BASE_URL", ",", "file_basename", "=", "None", ",", "file_id", "=", "None", ",", "all_files", "=", "False", ")", ":", "response", "=", "delete_file", "(", "access_toke...
Command line function for deleting files. For more information visit :func:`delete_file<ohapi.api.delete_file>`.
[ "Command", "line", "function", "for", "deleting", "files", ".", "For", "more", "information", "visit", ":", "func", ":", "delete_file<ohapi", ".", "api", ".", "delete_file", ">", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L491-L503
train
OpenHumans/open-humans-api
ohapi/command_line.py
public_data_download_cli
def public_data_download_cli(source, username, directory, max_size, quiet, debug): """ Command line tools for downloading public data. """ return public_download(source, username, directory, max_size, quiet, debug)
python
def public_data_download_cli(source, username, directory, max_size, quiet, debug): """ Command line tools for downloading public data. """ return public_download(source, username, directory, max_size, quiet, debug)
[ "def", "public_data_download_cli", "(", "source", ",", "username", ",", "directory", ",", "max_size", ",", "quiet", ",", "debug", ")", ":", "return", "public_download", "(", "source", ",", "username", ",", "directory", ",", "max_size", ",", "quiet", ",", "de...
Command line tools for downloading public data.
[ "Command", "line", "tools", "for", "downloading", "public", "data", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L517-L522
train
OpenHumans/open-humans-api
ohapi/public.py
download_url
def download_url(result, directory, max_bytes): """ Download a file. :param result: This field contains a url from which data will be downloaded. :param directory: This field is the target directory to which data will be downloaded. :param max_bytes: This field is the maximum file s...
python
def download_url(result, directory, max_bytes): """ Download a file. :param result: This field contains a url from which data will be downloaded. :param directory: This field is the target directory to which data will be downloaded. :param max_bytes: This field is the maximum file s...
[ "def", "download_url", "(", "result", ",", "directory", ",", "max_bytes", ")", ":", "response", "=", "requests", ".", "get", "(", "result", "[", "'download_url'", "]", ",", "stream", "=", "True", ")", "# TODO: make this more robust by parsing the URL", "filename",...
Download a file. :param result: This field contains a url from which data will be downloaded. :param directory: This field is the target directory to which data will be downloaded. :param max_bytes: This field is the maximum file size in bytes.
[ "Download", "a", "file", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L37-L99
train
OpenHumans/open-humans-api
ohapi/public.py
download
def download(source=None, username=None, directory='.', max_size='128m', quiet=None, debug=None): """ Download public data from Open Humans. :param source: This field is the data source from which to download. It's default value is None. :param username: This fiels is username of u...
python
def download(source=None, username=None, directory='.', max_size='128m', quiet=None, debug=None): """ Download public data from Open Humans. :param source: This field is the data source from which to download. It's default value is None. :param username: This fiels is username of u...
[ "def", "download", "(", "source", "=", "None", ",", "username", "=", "None", ",", "directory", "=", "'.'", ",", "max_size", "=", "'128m'", ",", "quiet", "=", "None", ",", "debug", "=", "None", ")", ":", "if", "debug", ":", "logging", ".", "basicConfi...
Download public data from Open Humans. :param source: This field is the data source from which to download. It's default value is None. :param username: This fiels is username of user. It's default value is None. :param directory: This field is the target directory to which data is ...
[ "Download", "public", "data", "from", "Open", "Humans", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L102-L172
train
OpenHumans/open-humans-api
ohapi/public.py
get_members_by_source
def get_members_by_source(base_url=BASE_URL_API): """ Function returns which members have joined each activity. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. """ url = '{}members-by-source/'.format(base_url) response = get_page(url) return response
python
def get_members_by_source(base_url=BASE_URL_API): """ Function returns which members have joined each activity. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. """ url = '{}members-by-source/'.format(base_url) response = get_page(url) return response
[ "def", "get_members_by_source", "(", "base_url", "=", "BASE_URL_API", ")", ":", "url", "=", "'{}members-by-source/'", ".", "format", "(", "base_url", ")", "response", "=", "get_page", "(", "url", ")", "return", "response" ]
Function returns which members have joined each activity. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`.
[ "Function", "returns", "which", "members", "have", "joined", "each", "activity", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L175-L183
train
OpenHumans/open-humans-api
ohapi/public.py
get_sources_by_member
def get_sources_by_member(base_url=BASE_URL_API, limit=LIMIT_DEFAULT): """ Function returns which activities each member has joined. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. :param limit: It is the limit of data send by one request. """ url = '{}sources-by-membe...
python
def get_sources_by_member(base_url=BASE_URL_API, limit=LIMIT_DEFAULT): """ Function returns which activities each member has joined. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. :param limit: It is the limit of data send by one request. """ url = '{}sources-by-membe...
[ "def", "get_sources_by_member", "(", "base_url", "=", "BASE_URL_API", ",", "limit", "=", "LIMIT_DEFAULT", ")", ":", "url", "=", "'{}sources-by-member/'", ".", "format", "(", "base_url", ")", "page", "=", "'{}?{}'", ".", "format", "(", "url", ",", "urlencode", ...
Function returns which activities each member has joined. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. :param limit: It is the limit of data send by one request.
[ "Function", "returns", "which", "activities", "each", "member", "has", "joined", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L186-L203
train
OpenHumans/open-humans-api
ohapi/projects.py
OHProject._get_member_file_data
def _get_member_file_data(member_data, id_filename=False): """ Helper function to get file data of member of a project. :param member_data: This field is data related to member in a project. """ file_data = {} for datafile in member_data['data']: if id_filena...
python
def _get_member_file_data(member_data, id_filename=False): """ Helper function to get file data of member of a project. :param member_data: This field is data related to member in a project. """ file_data = {} for datafile in member_data['data']: if id_filena...
[ "def", "_get_member_file_data", "(", "member_data", ",", "id_filename", "=", "False", ")", ":", "file_data", "=", "{", "}", "for", "datafile", "in", "member_data", "[", "'data'", "]", ":", "if", "id_filename", ":", "basename", "=", "'{}.{}'", ".", "format", ...
Helper function to get file data of member of a project. :param member_data: This field is data related to member in a project.
[ "Helper", "function", "to", "get", "file", "data", "of", "member", "of", "a", "project", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L27-L43
train
OpenHumans/open-humans-api
ohapi/projects.py
OHProject.update_data
def update_data(self): """ Returns data for all users including shared data files. """ url = ('https://www.openhumans.org/api/direct-sharing/project/' 'members/?access_token={}'.format(self.master_access_token)) results = get_all_results(url) self.project_d...
python
def update_data(self): """ Returns data for all users including shared data files. """ url = ('https://www.openhumans.org/api/direct-sharing/project/' 'members/?access_token={}'.format(self.master_access_token)) results = get_all_results(url) self.project_d...
[ "def", "update_data", "(", "self", ")", ":", "url", "=", "(", "'https://www.openhumans.org/api/direct-sharing/project/'", "'members/?access_token={}'", ".", "format", "(", "self", ".", "master_access_token", ")", ")", "results", "=", "get_all_results", "(", "url", ")"...
Returns data for all users including shared data files.
[ "Returns", "data", "for", "all", "users", "including", "shared", "data", "files", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L45-L63
train
OpenHumans/open-humans-api
ohapi/projects.py
OHProject.download_member_project_data
def download_member_project_data(cls, member_data, target_member_dir, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member project data. :param member_data: This field i...
python
def download_member_project_data(cls, member_data, target_member_dir, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member project data. :param member_data: This field i...
[ "def", "download_member_project_data", "(", "cls", ",", "member_data", ",", "target_member_dir", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ",", "id_filename", "=", "False", ")", ":", "logging", ".", "debug", "(", "'Download member project data...'", ")", "sources_shar...
Download files to sync a local dir to match OH member project data. :param member_data: This field is data related to member in a project. :param target_member_dir: This field is the target directory where data will be downloaded. :param max_size: This field is the maximum file size...
[ "Download", "files", "to", "sync", "a", "local", "dir", "to", "match", "OH", "member", "project", "data", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L66-L91
train
OpenHumans/open-humans-api
ohapi/projects.py
OHProject.download_member_shared
def download_member_shared(cls, member_data, target_member_dir, source=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member shared data. Files are downloaded to match their "basename" on Open Humans. ...
python
def download_member_shared(cls, member_data, target_member_dir, source=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member shared data. Files are downloaded to match their "basename" on Open Humans. ...
[ "def", "download_member_shared", "(", "cls", ",", "member_data", ",", "target_member_dir", ",", "source", "=", "None", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ",", "id_filename", "=", "False", ")", ":", "logging", ".", "debug", "(", "'Download member shared data...
Download files to sync a local dir to match OH member shared data. Files are downloaded to match their "basename" on Open Humans. If there are multiple files with the same name, the most recent is downloaded. :param member_data: This field is data related to member in a project. ...
[ "Download", "files", "to", "sync", "a", "local", "dir", "to", "match", "OH", "member", "shared", "data", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L94-L137
train
OpenHumans/open-humans-api
ohapi/projects.py
OHProject.download_all
def download_all(self, target_dir, source=None, project_data=False, memberlist=None, excludelist=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download data for all users including shared data files. :param target_dir: This field is the targe...
python
def download_all(self, target_dir, source=None, project_data=False, memberlist=None, excludelist=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download data for all users including shared data files. :param target_dir: This field is the targe...
[ "def", "download_all", "(", "self", ",", "target_dir", ",", "source", "=", "None", ",", "project_data", "=", "False", ",", "memberlist", "=", "None", ",", "excludelist", "=", "None", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ",", "id_filename", "=", "False",...
Download data for all users including shared data files. :param target_dir: This field is the target directory to download data. :param source: This field is the data source. It's default value is None. :param project_data: This field is data related to particular project. ...
[ "Download", "data", "for", "all", "users", "including", "shared", "data", "files", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L139-L180
train
OpenHumans/open-humans-api
ohapi/projects.py
OHProject.upload_member_from_dir
def upload_member_from_dir(member_data, target_member_dir, metadata, access_token, mode='default', max_size=MAX_SIZE_DEFAULT): """ Upload files in target directory to an Open Humans member's account. The default behavior is to overwr...
python
def upload_member_from_dir(member_data, target_member_dir, metadata, access_token, mode='default', max_size=MAX_SIZE_DEFAULT): """ Upload files in target directory to an Open Humans member's account. The default behavior is to overwr...
[ "def", "upload_member_from_dir", "(", "member_data", ",", "target_member_dir", ",", "metadata", ",", "access_token", ",", "mode", "=", "'default'", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ")", ":", "if", "not", "validate_metadata", "(", "target_member_dir", ",", ...
Upload files in target directory to an Open Humans member's account. The default behavior is to overwrite files with matching filenames on Open Humans, but not otherwise delete files. If the 'mode' parameter is 'safe': matching filenames will not be overwritten. If the 'mode' ...
[ "Upload", "files", "in", "target", "directory", "to", "an", "Open", "Humans", "member", "s", "account", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L183-L232
train
OpenHumans/open-humans-api
ohapi/api.py
oauth2_auth_url
def oauth2_auth_url(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Returns an OAuth2 authorization URL for a project, given Client ID. This function constructs an authorization URL for a user to follow. The user will be redirected to Authorize Open Humans data for our external applica...
python
def oauth2_auth_url(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Returns an OAuth2 authorization URL for a project, given Client ID. This function constructs an authorization URL for a user to follow. The user will be redirected to Authorize Open Humans data for our external applica...
[ "def", "oauth2_auth_url", "(", "redirect_uri", "=", "None", ",", "client_id", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ")", ":", "if", "not", "client_id", ":", "client_id", "=", "os", ".", "getenv", "(", "'OHAPI_CLIENT_ID'", ")", "if", "not", "cli...
Returns an OAuth2 authorization URL for a project, given Client ID. This function constructs an authorization URL for a user to follow. The user will be redirected to Authorize Open Humans data for our external application. An OAuth2 project on Open Humans is required for this to properly work. To learn...
[ "Returns", "an", "OAuth2", "authorization", "URL", "for", "a", "project", "given", "Client", "ID", ".", "This", "function", "constructs", "an", "authorization", "URL", "for", "a", "user", "to", "follow", ".", "The", "user", "will", "be", "redirected", "to", ...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L27-L60
train
OpenHumans/open-humans-api
ohapi/api.py
oauth2_token_exchange
def oauth2_token_exchange(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Exchange code or refresh token for a new token and refresh token. For the first time when a project is created, code is required to generate refresh token...
python
def oauth2_token_exchange(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Exchange code or refresh token for a new token and refresh token. For the first time when a project is created, code is required to generate refresh token...
[ "def", "oauth2_token_exchange", "(", "client_id", ",", "client_secret", ",", "redirect_uri", ",", "base_url", "=", "OH_BASE_URL", ",", "code", "=", "None", ",", "refresh_token", "=", "None", ")", ":", "if", "not", "(", "code", "or", "refresh_token", ")", "or...
Exchange code or refresh token for a new token and refresh token. For the first time when a project is created, code is required to generate refresh token. Once the refresh token is obtained, it can be used later on for obtaining new access token and refresh token. The user must store the refresh token ...
[ "Exchange", "code", "or", "refresh", "token", "for", "a", "new", "token", "and", "refresh", "token", ".", "For", "the", "first", "time", "when", "a", "project", "is", "created", "code", "is", "required", "to", "generate", "refresh", "token", ".", "Once", ...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L63-L101
train
OpenHumans/open-humans-api
ohapi/api.py
get_page
def get_page(url): """ Get a single page of results. :param url: This field is the url from which data will be requested. """ response = requests.get(url) handle_error(response, 200) data = response.json() return data
python
def get_page(url): """ Get a single page of results. :param url: This field is the url from which data will be requested. """ response = requests.get(url) handle_error(response, 200) data = response.json() return data
[ "def", "get_page", "(", "url", ")", ":", "response", "=", "requests", ".", "get", "(", "url", ")", "handle_error", "(", "response", ",", "200", ")", "data", "=", "response", ".", "json", "(", ")", "return", "data" ]
Get a single page of results. :param url: This field is the url from which data will be requested.
[ "Get", "a", "single", "page", "of", "results", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L104-L113
train
OpenHumans/open-humans-api
ohapi/api.py
get_all_results
def get_all_results(starting_page): """ Given starting API query for Open Humans, iterate to get all results. :param starting page: This field is the first page, starting from which results will be obtained. """ logging.info('Retrieving all results for {}'.format(starting_page)) page = ...
python
def get_all_results(starting_page): """ Given starting API query for Open Humans, iterate to get all results. :param starting page: This field is the first page, starting from which results will be obtained. """ logging.info('Retrieving all results for {}'.format(starting_page)) page = ...
[ "def", "get_all_results", "(", "starting_page", ")", ":", "logging", ".", "info", "(", "'Retrieving all results for {}'", ".", "format", "(", "starting_page", ")", ")", "page", "=", "starting_page", "results", "=", "[", "]", "while", "True", ":", "logging", "....
Given starting API query for Open Humans, iterate to get all results. :param starting page: This field is the first page, starting from which results will be obtained.
[ "Given", "starting", "API", "query", "for", "Open", "Humans", "iterate", "to", "get", "all", "results", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L116-L138
train
OpenHumans/open-humans-api
ohapi/api.py
exchange_oauth2_member
def exchange_oauth2_member(access_token, base_url=OH_BASE_URL, all_files=False): """ Returns data for a specific user, including shared data files. :param access_token: This field is the user specific access_token. :param base_url: It is this URL `https://www.openhumans.org`....
python
def exchange_oauth2_member(access_token, base_url=OH_BASE_URL, all_files=False): """ Returns data for a specific user, including shared data files. :param access_token: This field is the user specific access_token. :param base_url: It is this URL `https://www.openhumans.org`....
[ "def", "exchange_oauth2_member", "(", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "all_files", "=", "False", ")", ":", "url", "=", "urlparse", ".", "urljoin", "(", "base_url", ",", "'/api/direct-sharing/project/exchange-member/?{}'", ".", "format", "("...
Returns data for a specific user, including shared data files. :param access_token: This field is the user specific access_token. :param base_url: It is this URL `https://www.openhumans.org`.
[ "Returns", "data", "for", "a", "specific", "user", "including", "shared", "data", "files", "." ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L141-L164
train
OpenHumans/open-humans-api
ohapi/api.py
delete_file
def delete_file(access_token, project_member_id=None, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Delete project member files by file_basename, file_id, or all_files. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans....
python
def delete_file(access_token, project_member_id=None, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Delete project member files by file_basename, file_id, or all_files. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans....
[ "def", "delete_file", "(", "access_token", ",", "project_member_id", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ",", "file_basename", "=", "None", ",", "file_id", "=", "None", ",", "all_files", "=", "False", ")", ":", "url", "=", "urlparse", ".", "u...
Delete project member files by file_basename, file_id, or all_files. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/. :param access_token: This field is user specific access_token. :param project_member_id: This field is the pro...
[ "Delete", "project", "member", "files", "by", "file_basename", "file_id", "or", "all_files", ".", "To", "learn", "more", "about", "Open", "Humans", "OAuth2", "projects", "go", "to", ":", "https", ":", "//", "www", ".", "openhumans", ".", "org", "/", "direc...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L166-L203
train
OpenHumans/open-humans-api
ohapi/api.py
message
def message(subject, message, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL): """ Send an email to individual users or in bulk. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/ :param subj...
python
def message(subject, message, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL): """ Send an email to individual users or in bulk. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/ :param subj...
[ "def", "message", "(", "subject", ",", "message", ",", "access_token", ",", "all_members", "=", "False", ",", "project_member_ids", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ")", ":", "url", "=", "urlparse", ".", "urljoin", "(", "base_url", ",", "'...
Send an email to individual users or in bulk. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/ :param subject: This field is the subject of the email. :param message: This field is the body of the email. :param access_token: This is ...
[ "Send", "an", "email", "to", "individual", "users", "or", "in", "bulk", ".", "To", "learn", "more", "about", "Open", "Humans", "OAuth2", "projects", "go", "to", ":", "https", ":", "//", "www", ".", "openhumans", ".", "org", "/", "direct", "-", "sharing...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L214-L247
train
OpenHumans/open-humans-api
ohapi/api.py
handle_error
def handle_error(r, expected_code): """ Helper function to match reponse of a request to the expected status code :param r: This field is the response of request. :param expected_code: This field is the expected status code for the function. """ code = r.status_code if code != e...
python
def handle_error(r, expected_code): """ Helper function to match reponse of a request to the expected status code :param r: This field is the response of request. :param expected_code: This field is the expected status code for the function. """ code = r.status_code if code != e...
[ "def", "handle_error", "(", "r", ",", "expected_code", ")", ":", "code", "=", "r", ".", "status_code", "if", "code", "!=", "expected_code", ":", "info", "=", "'API response status code {}'", ".", "format", "(", "code", ")", "try", ":", "if", "'detail'", "i...
Helper function to match reponse of a request to the expected status code :param r: This field is the response of request. :param expected_code: This field is the expected status code for the function.
[ "Helper", "function", "to", "match", "reponse", "of", "a", "request", "to", "the", "expected", "status", "code" ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L258-L277
train
OpenHumans/open-humans-api
ohapi/api.py
upload_stream
def upload_stream(stream, filename, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT, file_identifier=None): """ Upload a file object using the "direct upload" feature, which uploads to ...
python
def upload_stream(stream, filename, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT, file_identifier=None): """ Upload a file object using the "direct upload" feature, which uploads to ...
[ "def", "upload_stream", "(", "stream", ",", "filename", ",", "metadata", ",", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "remote_file_info", "=", "None", ",", "project_member_id", "=", "None", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ",", "file_...
Upload a file object using the "direct upload" feature, which uploads to an S3 bucket URL provided by the Open Humans API. To learn more about this API endpoint see: * https://www.openhumans.org/direct-sharing/on-site-data-upload/ * https://www.openhumans.org/direct-sharing/oauth2-data-upload/ :par...
[ "Upload", "a", "file", "object", "using", "the", "direct", "upload", "feature", "which", "uploads", "to", "an", "S3", "bucket", "URL", "provided", "by", "the", "Open", "Humans", "API", ".", "To", "learn", "more", "about", "this", "API", "endpoint", "see", ...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L280-L355
train
OpenHumans/open-humans-api
ohapi/api.py
upload_file
def upload_file(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. To learn more about this API endpoint see: * h...
python
def upload_file(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. To learn more about this API endpoint see: * h...
[ "def", "upload_file", "(", "target_filepath", ",", "metadata", ",", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "remote_file_info", "=", "None", ",", "project_member_id", "=", "None", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "with", "op...
Upload a file from a local filepath using the "direct upload" API. To learn more about this API endpoint see: * https://www.openhumans.org/direct-sharing/on-site-data-upload/ * https://www.openhumans.org/direct-sharing/oauth2-data-upload/ :param target_filepath: This field is the filepath of the file t...
[ "Upload", "a", "file", "from", "a", "local", "filepath", "using", "the", "direct", "upload", "API", ".", "To", "learn", "more", "about", "this", "API", "endpoint", "see", ":", "*", "https", ":", "//", "www", ".", "openhumans", ".", "org", "/", "direct"...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L358-L385
train
OpenHumans/open-humans-api
ohapi/api.py
upload_aws
def upload_aws(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. Equivalent to upload_file. To learn more about this A...
python
def upload_aws(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. Equivalent to upload_file. To learn more about this A...
[ "def", "upload_aws", "(", "target_filepath", ",", "metadata", ",", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "remote_file_info", "=", "None", ",", "project_member_id", "=", "None", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "return", "u...
Upload a file from a local filepath using the "direct upload" API. Equivalent to upload_file. To learn more about this API endpoint see: * https://www.openhumans.org/direct-sharing/on-site-data-upload/ * https://www.openhumans.org/direct-sharing/oauth2-data-upload/ :param target_filepath: This field is...
[ "Upload", "a", "file", "from", "a", "local", "filepath", "using", "the", "direct", "upload", "API", ".", "Equivalent", "to", "upload_file", ".", "To", "learn", "more", "about", "this", "API", "endpoint", "see", ":", "*", "https", ":", "//", "www", ".", ...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L388-L411
train
tych0/xcffib
module/__init__.py
pack_list
def pack_list(from_, pack_type): """ Return the wire packed version of `from_`. `pack_type` should be some subclass of `xcffib.Struct`, or a string that can be passed to `struct.pack`. You must pass `size` if `pack_type` is a struct.pack string. """ # We need from_ to not be empty if len(from_) ...
python
def pack_list(from_, pack_type): """ Return the wire packed version of `from_`. `pack_type` should be some subclass of `xcffib.Struct`, or a string that can be passed to `struct.pack`. You must pass `size` if `pack_type` is a struct.pack string. """ # We need from_ to not be empty if len(from_) ...
[ "def", "pack_list", "(", "from_", ",", "pack_type", ")", ":", "# We need from_ to not be empty", "if", "len", "(", "from_", ")", "==", "0", ":", "return", "bytes", "(", ")", "if", "pack_type", "==", "'c'", ":", "if", "isinstance", "(", "from_", ",", "byt...
Return the wire packed version of `from_`. `pack_type` should be some subclass of `xcffib.Struct`, or a string that can be passed to `struct.pack`. You must pass `size` if `pack_type` is a struct.pack string.
[ "Return", "the", "wire", "packed", "version", "of", "from_", ".", "pack_type", "should", "be", "some", "subclass", "of", "xcffib", ".", "Struct", "or", "a", "string", "that", "can", "be", "passed", "to", "struct", ".", "pack", ".", "You", "must", "pass",...
c9c50c3ce513b130821f430be78c4c733626c707
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L751-L793
train
tych0/xcffib
module/__init__.py
Connection.ensure_connected
def ensure_connected(f): """ Check that the connection is valid both before and after the function is invoked. """ @functools.wraps(f) def wrapper(*args): self = args[0] self.invalid() try: return f(*args) fi...
python
def ensure_connected(f): """ Check that the connection is valid both before and after the function is invoked. """ @functools.wraps(f) def wrapper(*args): self = args[0] self.invalid() try: return f(*args) fi...
[ "def", "ensure_connected", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ")", ":", "self", "=", "args", "[", "0", "]", "self", ".", "invalid", "(", ")", "try", ":", "return", "f", "(", "*...
Check that the connection is valid both before and after the function is invoked.
[ "Check", "that", "the", "connection", "is", "valid", "both", "before", "and", "after", "the", "function", "is", "invoked", "." ]
c9c50c3ce513b130821f430be78c4c733626c707
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L560-L573
train
tych0/xcffib
module/__init__.py
Connection.get_screen_pointers
def get_screen_pointers(self): """ Returns the xcb_screen_t for every screen useful for other bindings """ root_iter = lib.xcb_setup_roots_iterator(self._setup) screens = [root_iter.data] for i in range(self._setup.roots_len - 1): lib.xcb_screen_next(...
python
def get_screen_pointers(self): """ Returns the xcb_screen_t for every screen useful for other bindings """ root_iter = lib.xcb_setup_roots_iterator(self._setup) screens = [root_iter.data] for i in range(self._setup.roots_len - 1): lib.xcb_screen_next(...
[ "def", "get_screen_pointers", "(", "self", ")", ":", "root_iter", "=", "lib", ".", "xcb_setup_roots_iterator", "(", "self", ".", "_setup", ")", "screens", "=", "[", "root_iter", ".", "data", "]", "for", "i", "in", "range", "(", "self", ".", "_setup", "."...
Returns the xcb_screen_t for every screen useful for other bindings
[ "Returns", "the", "xcb_screen_t", "for", "every", "screen", "useful", "for", "other", "bindings" ]
c9c50c3ce513b130821f430be78c4c733626c707
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L586-L597
train
tych0/xcffib
module/__init__.py
Connection.hoist_event
def hoist_event(self, e): """ Hoist an xcb_generic_event_t to the right xcffib structure. """ if e.response_type == 0: return self._process_error(ffi.cast("xcb_generic_error_t *", e)) # We mask off the high bit here because events sent with SendEvent have # this bit set. We ...
python
def hoist_event(self, e): """ Hoist an xcb_generic_event_t to the right xcffib structure. """ if e.response_type == 0: return self._process_error(ffi.cast("xcb_generic_error_t *", e)) # We mask off the high bit here because events sent with SendEvent have # this bit set. We ...
[ "def", "hoist_event", "(", "self", ",", "e", ")", ":", "if", "e", ".", "response_type", "==", "0", ":", "return", "self", ".", "_process_error", "(", "ffi", ".", "cast", "(", "\"xcb_generic_error_t *\"", ",", "e", ")", ")", "# We mask off the high bit here b...
Hoist an xcb_generic_event_t to the right xcffib structure.
[ "Hoist", "an", "xcb_generic_event_t", "to", "the", "right", "xcffib", "structure", "." ]
c9c50c3ce513b130821f430be78c4c733626c707
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L681-L693
train
debrouwere/google-analytics
googleanalytics/columns.py
ColumnList.serialize
def serialize(self, value, greedy=True): """ Greedy serialization requires the value to either be a column or convertible to a column, whereas non-greedy serialization will pass through any string as-is and will only serialize Column objects. Non-greedy serialization is ...
python
def serialize(self, value, greedy=True): """ Greedy serialization requires the value to either be a column or convertible to a column, whereas non-greedy serialization will pass through any string as-is and will only serialize Column objects. Non-greedy serialization is ...
[ "def", "serialize", "(", "self", ",", "value", ",", "greedy", "=", "True", ")", ":", "if", "greedy", "and", "not", "isinstance", "(", "value", ",", "Column", ")", ":", "value", "=", "self", ".", "normalize", "(", "value", ")", "if", "isinstance", "("...
Greedy serialization requires the value to either be a column or convertible to a column, whereas non-greedy serialization will pass through any string as-is and will only serialize Column objects. Non-greedy serialization is useful when preparing queries with custom filters or ...
[ "Greedy", "serialization", "requires", "the", "value", "to", "either", "be", "a", "column", "or", "convertible", "to", "a", "column", "whereas", "non", "-", "greedy", "serialization", "will", "pass", "through", "any", "string", "as", "-", "is", "and", "will"...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/columns.py#L237-L254
train
debrouwere/google-analytics
googleanalytics/query.py
describe
def describe(profile, description): """ Generate a query by describing it as a series of actions and parameters to those actions. These map directly to Query methods and arguments to those methods. This is an alternative to the chaining interface. Mostly useful if you'd like to put your queries...
python
def describe(profile, description): """ Generate a query by describing it as a series of actions and parameters to those actions. These map directly to Query methods and arguments to those methods. This is an alternative to the chaining interface. Mostly useful if you'd like to put your queries...
[ "def", "describe", "(", "profile", ",", "description", ")", ":", "api_type", "=", "description", ".", "pop", "(", "'type'", ",", "'core'", ")", "api", "=", "getattr", "(", "profile", ",", "api_type", ")", "return", "refine", "(", "api", ".", "query", "...
Generate a query by describing it as a series of actions and parameters to those actions. These map directly to Query methods and arguments to those methods. This is an alternative to the chaining interface. Mostly useful if you'd like to put your queries in a file, rather than in Python code.
[ "Generate", "a", "query", "by", "describing", "it", "as", "a", "series", "of", "actions", "and", "parameters", "to", "those", "actions", ".", "These", "map", "directly", "to", "Query", "methods", "and", "arguments", "to", "those", "methods", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1093-L1105
train
debrouwere/google-analytics
googleanalytics/query.py
refine
def refine(query, description): """ Refine a query from a dictionary of parameters that describes it. See `describe` for more information. """ for attribute, arguments in description.items(): if hasattr(query, attribute): attribute = getattr(query, attribute) else: ...
python
def refine(query, description): """ Refine a query from a dictionary of parameters that describes it. See `describe` for more information. """ for attribute, arguments in description.items(): if hasattr(query, attribute): attribute = getattr(query, attribute) else: ...
[ "def", "refine", "(", "query", ",", "description", ")", ":", "for", "attribute", ",", "arguments", "in", "description", ".", "items", "(", ")", ":", "if", "hasattr", "(", "query", ",", "attribute", ")", ":", "attribute", "=", "getattr", "(", "query", "...
Refine a query from a dictionary of parameters that describes it. See `describe` for more information.
[ "Refine", "a", "query", "from", "a", "dictionary", "of", "parameters", "that", "describes", "it", ".", "See", "describe", "for", "more", "information", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1107-L1135
train
debrouwere/google-analytics
googleanalytics/query.py
Query.set
def set(self, key=None, value=None, **kwargs): """ `set` is a way to add raw properties to the request, for features that this module does not support or supports incompletely. For convenience's sake, it will serialize Column objects but will leave any other kind of value...
python
def set(self, key=None, value=None, **kwargs): """ `set` is a way to add raw properties to the request, for features that this module does not support or supports incompletely. For convenience's sake, it will serialize Column objects but will leave any other kind of value...
[ "def", "set", "(", "self", ",", "key", "=", "None", ",", "value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "serialize", "=", "partial", "(", "self", ".", "api", ".", "columns", ".", "serialize", ",", "greedy", "=", "False", ")", "if", "key...
`set` is a way to add raw properties to the request, for features that this module does not support or supports incompletely. For convenience's sake, it will serialize Column objects but will leave any other kind of value alone.
[ "set", "is", "a", "way", "to", "add", "raw", "properties", "to", "the", "request", "for", "features", "that", "this", "module", "does", "not", "support", "or", "supports", "incompletely", ".", "For", "convenience", "s", "sake", "it", "will", "serialize", "...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L430-L451
train
debrouwere/google-analytics
googleanalytics/query.py
Query.description
def description(self): """ A list of the metrics this query will ask for. """ if 'metrics' in self.raw: metrics = self.raw['metrics'] head = metrics[0:-1] or metrics[0:1] text = ", ".join(head) if len(metrics) > 1: tail = m...
python
def description(self): """ A list of the metrics this query will ask for. """ if 'metrics' in self.raw: metrics = self.raw['metrics'] head = metrics[0:-1] or metrics[0:1] text = ", ".join(head) if len(metrics) > 1: tail = m...
[ "def", "description", "(", "self", ")", ":", "if", "'metrics'", "in", "self", ".", "raw", ":", "metrics", "=", "self", ".", "raw", "[", "'metrics'", "]", "head", "=", "metrics", "[", "0", ":", "-", "1", "]", "or", "metrics", "[", "0", ":", "1", ...
A list of the metrics this query will ask for.
[ "A", "list", "of", "the", "metrics", "this", "query", "will", "ask", "for", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L469-L484
train
debrouwere/google-analytics
googleanalytics/query.py
Query.sort
def sort(self, *columns, **options): """ Return a new query which will produce results sorted by one or more metrics or dimensions. You may use plain strings for the columns, or actual `Column`, `Metric` and `Dimension` objects. Add a minus in front of the metric (either...
python
def sort(self, *columns, **options): """ Return a new query which will produce results sorted by one or more metrics or dimensions. You may use plain strings for the columns, or actual `Column`, `Metric` and `Dimension` objects. Add a minus in front of the metric (either...
[ "def", "sort", "(", "self", ",", "*", "columns", ",", "*", "*", "options", ")", ":", "sorts", "=", "self", ".", "meta", ".", "setdefault", "(", "'sort'", ",", "[", "]", ")", "for", "column", "in", "columns", ":", "if", "isinstance", "(", "column", ...
Return a new query which will produce results sorted by one or more metrics or dimensions. You may use plain strings for the columns, or actual `Column`, `Metric` and `Dimension` objects. Add a minus in front of the metric (either the string or the object) to sort in descending ...
[ "Return", "a", "new", "query", "which", "will", "produce", "results", "sorted", "by", "one", "or", "more", "metrics", "or", "dimensions", ".", "You", "may", "use", "plain", "strings", "for", "the", "columns", "or", "actual", "Column", "Metric", "and", "Dim...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L515-L556
train
debrouwere/google-analytics
googleanalytics/query.py
Query.filter
def filter(self, value=None, exclude=False, **selection): """ Most of the actual functionality lives on the Column object and the `all` and `any` functions. """ filters = self.meta.setdefault('filters', []) if value and len(selection): raise ValueError("Cannot specify a filt...
python
def filter(self, value=None, exclude=False, **selection): """ Most of the actual functionality lives on the Column object and the `all` and `any` functions. """ filters = self.meta.setdefault('filters', []) if value and len(selection): raise ValueError("Cannot specify a filt...
[ "def", "filter", "(", "self", ",", "value", "=", "None", ",", "exclude", "=", "False", ",", "*", "*", "selection", ")", ":", "filters", "=", "self", ".", "meta", ".", "setdefault", "(", "'filters'", ",", "[", "]", ")", "if", "value", "and", "len", ...
Most of the actual functionality lives on the Column object and the `all` and `any` functions.
[ "Most", "of", "the", "actual", "functionality", "lives", "on", "the", "Column", "object", "and", "the", "all", "and", "any", "functions", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L559-L573
train
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.precision
def precision(self, precision): """ For queries that should run faster, you may specify a lower precision, and for those that need to be more precise, a higher precision: ```python # faster queries query.range('2014-01-01', '2014-01-31', precision=0) query.range(...
python
def precision(self, precision): """ For queries that should run faster, you may specify a lower precision, and for those that need to be more precise, a higher precision: ```python # faster queries query.range('2014-01-01', '2014-01-31', precision=0) query.range(...
[ "def", "precision", "(", "self", ",", "precision", ")", ":", "if", "isinstance", "(", "precision", ",", "int", ")", ":", "precision", "=", "self", ".", "PRECISION_LEVELS", "[", "precision", "]", "if", "precision", "not", "in", "self", ".", "PRECISION_LEVEL...
For queries that should run faster, you may specify a lower precision, and for those that need to be more precise, a higher precision: ```python # faster queries query.range('2014-01-01', '2014-01-31', precision=0) query.range('2014-01-01', '2014-01-31', precision='FASTER') ...
[ "For", "queries", "that", "should", "run", "faster", "you", "may", "specify", "a", "lower", "precision", "and", "for", "those", "that", "need", "to", "be", "more", "precise", "a", "higher", "precision", ":" ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L702-L731
train
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.interval
def interval(self, granularity): """ Note that if you don't specify a granularity (either through the `interval` method or through the `hourly`, `daily`, `weekly`, `monthly` or `yearly` shortcut methods) you will get only a single result, encompassing the entire date range, per m...
python
def interval(self, granularity): """ Note that if you don't specify a granularity (either through the `interval` method or through the `hourly`, `daily`, `weekly`, `monthly` or `yearly` shortcut methods) you will get only a single result, encompassing the entire date range, per m...
[ "def", "interval", "(", "self", ",", "granularity", ")", ":", "if", "granularity", "==", "'total'", ":", "return", "self", "if", "not", "isinstance", "(", "granularity", ",", "int", ")", ":", "if", "granularity", "in", "self", ".", "GRANULARITY_LEVELS", ":...
Note that if you don't specify a granularity (either through the `interval` method or through the `hourly`, `daily`, `weekly`, `monthly` or `yearly` shortcut methods) you will get only a single result, encompassing the entire date range, per metric.
[ "Note", "that", "if", "you", "don", "t", "specify", "a", "granularity", "(", "either", "through", "the", "interval", "method", "or", "through", "the", "hourly", "daily", "weekly", "monthly", "or", "yearly", "shortcut", "methods", ")", "you", "will", "get", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L734-L755
train
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.range
def range(self, start=None, stop=None, months=0, days=0): """ Return a new query that fetches metrics within a certain date range. ```python query.range('2014-01-01', '2014-06-30') ``` If you don't specify a `stop` argument, the date range will end today. If instead ...
python
def range(self, start=None, stop=None, months=0, days=0): """ Return a new query that fetches metrics within a certain date range. ```python query.range('2014-01-01', '2014-06-30') ``` If you don't specify a `stop` argument, the date range will end today. If instead ...
[ "def", "range", "(", "self", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "months", "=", "0", ",", "days", "=", "0", ")", ":", "start", ",", "stop", "=", "utils", ".", "date", ".", "range", "(", "start", ",", "stop", ",", "months",...
Return a new query that fetches metrics within a certain date range. ```python query.range('2014-01-01', '2014-06-30') ``` If you don't specify a `stop` argument, the date range will end today. If instead you meant to fetch just a single day's results, try: ```python ...
[ "Return", "a", "new", "query", "that", "fetches", "metrics", "within", "a", "certain", "date", "range", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L758-L798
train
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.limit
def limit(self, *_range): """ Return a new query, limited to a certain number of results. ```python # first 100 query.limit(100) # 50 to 60 query.limit(50, 10) ``` Please note carefully that Google Analytics uses 1-indexing on its rows. ...
python
def limit(self, *_range): """ Return a new query, limited to a certain number of results. ```python # first 100 query.limit(100) # 50 to 60 query.limit(50, 10) ``` Please note carefully that Google Analytics uses 1-indexing on its rows. ...
[ "def", "limit", "(", "self", ",", "*", "_range", ")", ":", "# uses the same argument order as", "# LIMIT in a SQL database", "if", "len", "(", "_range", ")", "==", "2", ":", "start", ",", "maximum", "=", "_range", "else", ":", "start", "=", "1", "maximum", ...
Return a new query, limited to a certain number of results. ```python # first 100 query.limit(100) # 50 to 60 query.limit(50, 10) ``` Please note carefully that Google Analytics uses 1-indexing on its rows.
[ "Return", "a", "new", "query", "limited", "to", "a", "certain", "number", "of", "results", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L866-L895
train
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.segment
def segment(self, value=None, scope=None, metric_scope=None, **selection): """ Return a new query, limited to a segment of all users or sessions. Accepts segment objects, filtered segment objects and segment names: ```python query.segment(account.segments['browser']) qu...
python
def segment(self, value=None, scope=None, metric_scope=None, **selection): """ Return a new query, limited to a segment of all users or sessions. Accepts segment objects, filtered segment objects and segment names: ```python query.segment(account.segments['browser']) qu...
[ "def", "segment", "(", "self", ",", "value", "=", "None", ",", "scope", "=", "None", ",", "metric_scope", "=", "None", ",", "*", "*", "selection", ")", ":", "\"\"\"\n Technical note to self about segments:\n\n * users or sessions\n * sequence or condi...
Return a new query, limited to a segment of all users or sessions. Accepts segment objects, filtered segment objects and segment names: ```python query.segment(account.segments['browser']) query.segment('browser') query.segment(account.segments['browser'].any('Chrome', 'Firefox...
[ "Return", "a", "new", "query", "limited", "to", "a", "segment", "of", "all", "users", "or", "sessions", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L909-L1003
train
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.next
def next(self): """ Return a new query with a modified `start_index`. Mainly used internally to paginate through results. """ step = self.raw.get('max_results', 1000) start = self.raw.get('start_index', 1) + step self.raw['start_index'] = start return self
python
def next(self): """ Return a new query with a modified `start_index`. Mainly used internally to paginate through results. """ step = self.raw.get('max_results', 1000) start = self.raw.get('start_index', 1) + step self.raw['start_index'] = start return self
[ "def", "next", "(", "self", ")", ":", "step", "=", "self", ".", "raw", ".", "get", "(", "'max_results'", ",", "1000", ")", "start", "=", "self", ".", "raw", ".", "get", "(", "'start_index'", ",", "1", ")", "+", "step", "self", ".", "raw", "[", ...
Return a new query with a modified `start_index`. Mainly used internally to paginate through results.
[ "Return", "a", "new", "query", "with", "a", "modified", "start_index", ".", "Mainly", "used", "internally", "to", "paginate", "through", "results", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1012-L1020
train
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.get
def get(self): """ Run the query and return a `Report`. This method transparently handles paginated results, so even for results that are larger than the maximum amount of rows the Google Analytics API will return in a single request, or larger than the amount of rows as specifi...
python
def get(self): """ Run the query and return a `Report`. This method transparently handles paginated results, so even for results that are larger than the maximum amount of rows the Google Analytics API will return in a single request, or larger than the amount of rows as specifi...
[ "def", "get", "(", "self", ")", ":", "cursor", "=", "self", "report", "=", "None", "is_complete", "=", "False", "is_enough", "=", "False", "while", "not", "(", "is_enough", "or", "is_complete", ")", ":", "chunk", "=", "cursor", ".", "execute", "(", ")"...
Run the query and return a `Report`. This method transparently handles paginated results, so even for results that are larger than the maximum amount of rows the Google Analytics API will return in a single request, or larger than the amount of rows as specified through `CoreQuery#step`...
[ "Run", "the", "query", "and", "return", "a", "Report", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1022-L1050
train
debrouwere/google-analytics
googleanalytics/query.py
RealTimeQuery.limit
def limit(self, maximum): """ Return a new query, limited to a certain number of results. Unlike core reporting queries, you cannot specify a starting point for live queries, just the maximum results returned. ```python # first 50 query.limit(50) ``` ...
python
def limit(self, maximum): """ Return a new query, limited to a certain number of results. Unlike core reporting queries, you cannot specify a starting point for live queries, just the maximum results returned. ```python # first 50 query.limit(50) ``` ...
[ "def", "limit", "(", "self", ",", "maximum", ")", ":", "self", ".", "meta", "[", "'limit'", "]", "=", "maximum", "self", ".", "raw", ".", "update", "(", "{", "'max_results'", ":", "maximum", ",", "}", ")", "return", "self" ]
Return a new query, limited to a certain number of results. Unlike core reporting queries, you cannot specify a starting point for live queries, just the maximum results returned. ```python # first 50 query.limit(50) ```
[ "Return", "a", "new", "query", "limited", "to", "a", "certain", "number", "of", "results", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1068-L1085
train
debrouwere/google-analytics
googleanalytics/auth/credentials.py
Credentials.valid
def valid(self): """ Valid credentials are not necessarily correct, but they contain all necessary information for an authentication attempt. """ two_legged = self.client_email and self.private_key three_legged = self.client_id and self.client_secret return two_legged or ...
python
def valid(self): """ Valid credentials are not necessarily correct, but they contain all necessary information for an authentication attempt. """ two_legged = self.client_email and self.private_key three_legged = self.client_id and self.client_secret return two_legged or ...
[ "def", "valid", "(", "self", ")", ":", "two_legged", "=", "self", ".", "client_email", "and", "self", ".", "private_key", "three_legged", "=", "self", ".", "client_id", "and", "self", ".", "client_secret", "return", "two_legged", "or", "three_legged", "or", ...
Valid credentials are not necessarily correct, but they contain all necessary information for an authentication attempt.
[ "Valid", "credentials", "are", "not", "necessarily", "correct", "but", "they", "contain", "all", "necessary", "information", "for", "an", "authentication", "attempt", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/credentials.py#L136-L142
train
debrouwere/google-analytics
googleanalytics/auth/credentials.py
Credentials.complete
def complete(self): """ Complete credentials are valid and are either two-legged or include a token. """ return self.valid and (self.access_token or self.refresh_token or self.type == 2)
python
def complete(self): """ Complete credentials are valid and are either two-legged or include a token. """ return self.valid and (self.access_token or self.refresh_token or self.type == 2)
[ "def", "complete", "(", "self", ")", ":", "return", "self", ".", "valid", "and", "(", "self", ".", "access_token", "or", "self", ".", "refresh_token", "or", "self", ".", "type", "==", "2", ")" ]
Complete credentials are valid and are either two-legged or include a token.
[ "Complete", "credentials", "are", "valid", "and", "are", "either", "two", "-", "legged", "or", "include", "a", "token", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/credentials.py#L149-L151
train
debrouwere/google-analytics
googleanalytics/auth/__init__.py
authenticate
def authenticate( client_id=None, client_secret=None, client_email=None, private_key=None, access_token=None, refresh_token=None, account=None, webproperty=None, profile=None, identity=None, prefix=None, suffix=None, interactive=False, save=False): """ The `authen...
python
def authenticate( client_id=None, client_secret=None, client_email=None, private_key=None, access_token=None, refresh_token=None, account=None, webproperty=None, profile=None, identity=None, prefix=None, suffix=None, interactive=False, save=False): """ The `authen...
[ "def", "authenticate", "(", "client_id", "=", "None", ",", "client_secret", "=", "None", ",", "client_email", "=", "None", ",", "private_key", "=", "None", ",", "access_token", "=", "None", ",", "refresh_token", "=", "None", ",", "account", "=", "None", ",...
The `authenticate` function will authenticate the user with the Google Analytics API, using a variety of strategies: keyword arguments provided to this function, credentials stored in in environment variables, credentials stored in the keychain and, finally, by asking for missing information interactively i...
[ "The", "authenticate", "function", "will", "authenticate", "the", "user", "with", "the", "Google", "Analytics", "API", "using", "a", "variety", "of", "strategies", ":", "keyword", "arguments", "provided", "to", "this", "function", "credentials", "stored", "in", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/__init__.py#L43-L97
train
debrouwere/google-analytics
googleanalytics/auth/__init__.py
revoke
def revoke(client_id, client_secret, client_email=None, private_key=None, access_token=None, refresh_token=None, identity=None, prefix=None, suffix=None): """ Given a client id, client secret and either an access token or a refresh token, revoke OAuth access to the Google Analytics ...
python
def revoke(client_id, client_secret, client_email=None, private_key=None, access_token=None, refresh_token=None, identity=None, prefix=None, suffix=None): """ Given a client id, client secret and either an access token or a refresh token, revoke OAuth access to the Google Analytics ...
[ "def", "revoke", "(", "client_id", ",", "client_secret", ",", "client_email", "=", "None", ",", "private_key", "=", "None", ",", "access_token", "=", "None", ",", "refresh_token", "=", "None", ",", "identity", "=", "None", ",", "prefix", "=", "None", ",", ...
Given a client id, client secret and either an access token or a refresh token, revoke OAuth access to the Google Analytics data and remove any stored credentials that use these tokens.
[ "Given", "a", "client", "id", "client", "secret", "and", "either", "an", "access", "token", "or", "a", "refresh", "token", "revoke", "OAuth", "access", "to", "the", "Google", "Analytics", "data", "and", "remove", "any", "stored", "credentials", "that", "use"...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/__init__.py#L123-L151
train
debrouwere/google-analytics
googleanalytics/commands/query.py
query
def query(scope, blueprint, debug, output, with_metadata, realtime, **description): """ e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensi...
python
def query(scope, blueprint, debug, output, with_metadata, realtime, **description): """ e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensi...
[ "def", "query", "(", "scope", ",", "blueprint", ",", "debug", ",", "output", ",", "with_metadata", ",", "realtime", ",", "*", "*", "description", ")", ":", "if", "realtime", ":", "description", "[", "'type'", "]", "=", "'realtime'", "if", "blueprint", ":...
e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensions pagepath \ --debug
[ "e", ".", "g", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/commands/query.py#L102-L130
train
debrouwere/google-analytics
googleanalytics/utils/functional.py
vectorize
def vectorize(fn): """ Allows a method to accept one or more values, but internally deal only with a single item, and returning a list or a single item depending on what is desired. """ @functools.wraps(fn) def vectorized_method(self, values, *vargs, **kwargs): wrap = not isinst...
python
def vectorize(fn): """ Allows a method to accept one or more values, but internally deal only with a single item, and returning a list or a single item depending on what is desired. """ @functools.wraps(fn) def vectorized_method(self, values, *vargs, **kwargs): wrap = not isinst...
[ "def", "vectorize", "(", "fn", ")", ":", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "vectorized_method", "(", "self", ",", "values", ",", "*", "vargs", ",", "*", "*", "kwargs", ")", ":", "wrap", "=", "not", "isinstance", "(", "values", ...
Allows a method to accept one or more values, but internally deal only with a single item, and returning a list or a single item depending on what is desired.
[ "Allows", "a", "method", "to", "accept", "one", "or", "more", "values", "but", "internally", "deal", "only", "with", "a", "single", "item", "and", "returning", "a", "list", "or", "a", "single", "item", "depending", "on", "what", "is", "desired", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/utils/functional.py#L20-L45
train
debrouwere/google-analytics
googleanalytics/account.py
Account.webproperties
def webproperties(self): """ A list of all web properties on this account. You may select a specific web property using its name, its id or an index. ```python account.webproperties[0] account.webproperties['UA-9234823-5'] account.webproperties['debrouwer...
python
def webproperties(self): """ A list of all web properties on this account. You may select a specific web property using its name, its id or an index. ```python account.webproperties[0] account.webproperties['UA-9234823-5'] account.webproperties['debrouwer...
[ "def", "webproperties", "(", "self", ")", ":", "raw_properties", "=", "self", ".", "service", ".", "management", "(", ")", ".", "webproperties", "(", ")", ".", "list", "(", "accountId", "=", "self", ".", "id", ")", ".", "execute", "(", ")", "[", "'it...
A list of all web properties on this account. You may select a specific web property using its name, its id or an index. ```python account.webproperties[0] account.webproperties['UA-9234823-5'] account.webproperties['debrouwere.org'] ```
[ "A", "list", "of", "all", "web", "properties", "on", "this", "account", ".", "You", "may", "select", "a", "specific", "web", "property", "using", "its", "name", "its", "id", "or", "an", "index", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/account.py#L47-L63
train
debrouwere/google-analytics
googleanalytics/account.py
WebProperty.profiles
def profiles(self): """ A list of all profiles on this web property. You may select a specific profile using its name, its id or an index. ```python property.profiles[0] property.profiles['9234823'] property.profiles['marketing profile'] ``` ...
python
def profiles(self): """ A list of all profiles on this web property. You may select a specific profile using its name, its id or an index. ```python property.profiles[0] property.profiles['9234823'] property.profiles['marketing profile'] ``` ...
[ "def", "profiles", "(", "self", ")", ":", "raw_profiles", "=", "self", ".", "account", ".", "service", ".", "management", "(", ")", ".", "profiles", "(", ")", ".", "list", "(", "accountId", "=", "self", ".", "account", ".", "id", ",", "webPropertyId", ...
A list of all profiles on this web property. You may select a specific profile using its name, its id or an index. ```python property.profiles[0] property.profiles['9234823'] property.profiles['marketing profile'] ```
[ "A", "list", "of", "all", "profiles", "on", "this", "web", "property", ".", "You", "may", "select", "a", "specific", "profile", "using", "its", "name", "its", "id", "or", "an", "index", "." ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/account.py#L98-L114
train
jfilter/text-classification-keras
texcla/libs/fastTextWikiTokenizer/subprocess_fix.py
check_output_input
def check_output_input(*popenargs, **kwargs): """Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. ...
python
def check_output_input(*popenargs, **kwargs): """Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. ...
[ "def", "check_output_input", "(", "*", "popenargs", ",", "*", "*", "kwargs", ")", ":", "if", "'stdout'", "in", "kwargs", ":", "raise", "ValueError", "(", "'stdout argument not allowed, it will be overridden.'", ")", "if", "'input'", "in", "kwargs", ":", "if", "'...
Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen construc...
[ "Run", "command", "with", "arguments", "and", "return", "its", "output", "as", "a", "byte", "string", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/libs/fastTextWikiTokenizer/subprocess_fix.py#L7-L63
train
jfilter/text-classification-keras
texcla/preprocessing/tokenizer.py
Tokenizer.create_token_indices
def create_token_indices(self, tokens): """If `apply_encoding_options` is inadequate, one can retrieve tokens from `self.token_counts`, filter with a desired strategy and regenerate `token_index` using this method. The token index is subsequently used when `encode_texts` or `decode_texts` method...
python
def create_token_indices(self, tokens): """If `apply_encoding_options` is inadequate, one can retrieve tokens from `self.token_counts`, filter with a desired strategy and regenerate `token_index` using this method. The token index is subsequently used when `encode_texts` or `decode_texts` method...
[ "def", "create_token_indices", "(", "self", ",", "tokens", ")", ":", "start_index", "=", "len", "(", "self", ".", "special_token", ")", "indices", "=", "list", "(", "range", "(", "len", "(", "tokens", ")", "+", "start_index", ")", ")", "# prepend because t...
If `apply_encoding_options` is inadequate, one can retrieve tokens from `self.token_counts`, filter with a desired strategy and regenerate `token_index` using this method. The token index is subsequently used when `encode_texts` or `decode_texts` methods are called.
[ "If", "apply_encoding_options", "is", "inadequate", "one", "can", "retrieve", "tokens", "from", "self", ".", "token_counts", "filter", "with", "a", "desired", "strategy", "and", "regenerate", "token_index", "using", "this", "method", ".", "The", "token", "index", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L70-L80
train
jfilter/text-classification-keras
texcla/preprocessing/tokenizer.py
Tokenizer.apply_encoding_options
def apply_encoding_options(self, min_token_count=1, limit_top_tokens=None): """Applies the given settings for subsequent calls to `encode_texts` and `decode_texts`. This allows you to play with different settings without having to re-run tokenization on the entire corpus. Args: min_...
python
def apply_encoding_options(self, min_token_count=1, limit_top_tokens=None): """Applies the given settings for subsequent calls to `encode_texts` and `decode_texts`. This allows you to play with different settings without having to re-run tokenization on the entire corpus. Args: min_...
[ "def", "apply_encoding_options", "(", "self", ",", "min_token_count", "=", "1", ",", "limit_top_tokens", "=", "None", ")", ":", "if", "not", "self", ".", "has_vocab", ":", "raise", "ValueError", "(", "\"You need to build the vocabulary using `build_vocab` \"", "\"befo...
Applies the given settings for subsequent calls to `encode_texts` and `decode_texts`. This allows you to play with different settings without having to re-run tokenization on the entire corpus. Args: min_token_count: The minimum token count (frequency) in order to include during encoding. A...
[ "Applies", "the", "given", "settings", "for", "subsequent", "calls", "to", "encode_texts", "and", "decode_texts", ".", "This", "allows", "you", "to", "play", "with", "different", "settings", "without", "having", "to", "re", "-", "run", "tokenization", "on", "t...
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L82-L111
train
jfilter/text-classification-keras
texcla/preprocessing/tokenizer.py
Tokenizer.encode_texts
def encode_texts(self, texts, unknown_token="<UNK>", verbose=1, **kwargs): """Encodes the given texts using internal vocabulary with optionally applied encoding options. See ``apply_encoding_options` to set various options. Args: texts: The list of text items to encode. ...
python
def encode_texts(self, texts, unknown_token="<UNK>", verbose=1, **kwargs): """Encodes the given texts using internal vocabulary with optionally applied encoding options. See ``apply_encoding_options` to set various options. Args: texts: The list of text items to encode. ...
[ "def", "encode_texts", "(", "self", ",", "texts", ",", "unknown_token", "=", "\"<UNK>\"", ",", "verbose", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "has_vocab", ":", "raise", "ValueError", "(", "\"You need to build the vocabulary...
Encodes the given texts using internal vocabulary with optionally applied encoding options. See ``apply_encoding_options` to set various options. Args: texts: The list of text items to encode. unknown_token: The token to replace words that out of vocabulary. If none, those words...
[ "Encodes", "the", "given", "texts", "using", "internal", "vocabulary", "with", "optionally", "applied", "encoding", "options", ".", "See", "apply_encoding_options", "to", "set", "various", "options", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L113-L151
train
jfilter/text-classification-keras
texcla/preprocessing/tokenizer.py
Tokenizer.decode_texts
def decode_texts(self, encoded_texts, unknown_token="<UNK>", inplace=True): """Decodes the texts using internal vocabulary. The list structure is maintained. Args: encoded_texts: The list of texts to decode. unknown_token: The placeholder value for unknown token. (Default value:...
python
def decode_texts(self, encoded_texts, unknown_token="<UNK>", inplace=True): """Decodes the texts using internal vocabulary. The list structure is maintained. Args: encoded_texts: The list of texts to decode. unknown_token: The placeholder value for unknown token. (Default value:...
[ "def", "decode_texts", "(", "self", ",", "encoded_texts", ",", "unknown_token", "=", "\"<UNK>\"", ",", "inplace", "=", "True", ")", ":", "if", "len", "(", "self", ".", "_token2idx", ")", "==", "0", ":", "raise", "ValueError", "(", "\"You need to build vocabu...
Decodes the texts using internal vocabulary. The list structure is maintained. Args: encoded_texts: The list of texts to decode. unknown_token: The placeholder value for unknown token. (Default value: "<UNK>") inplace: True to make changes inplace. (Default value: True) ...
[ "Decodes", "the", "texts", "using", "internal", "vocabulary", ".", "The", "list", "structure", "is", "maintained", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L153-L176
train
jfilter/text-classification-keras
texcla/preprocessing/tokenizer.py
Tokenizer.build_vocab
def build_vocab(self, texts, verbose=1, **kwargs): """Builds the internal vocabulary and computes various statistics. Args: texts: The list of text items to encode. verbose: The verbosity level for progress. Can be 0, 1, 2. (Default value = 1) **kwargs: The kwargs fo...
python
def build_vocab(self, texts, verbose=1, **kwargs): """Builds the internal vocabulary and computes various statistics. Args: texts: The list of text items to encode. verbose: The verbosity level for progress. Can be 0, 1, 2. (Default value = 1) **kwargs: The kwargs fo...
[ "def", "build_vocab", "(", "self", ",", "texts", ",", "verbose", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "has_vocab", ":", "logger", ".", "warn", "(", "\"Tokenizer already has existing vocabulary. Overriding and building new vocabulary.\"", ...
Builds the internal vocabulary and computes various statistics. Args: texts: The list of text items to encode. verbose: The verbosity level for progress. Can be 0, 1, 2. (Default value = 1) **kwargs: The kwargs for `token_generator`.
[ "Builds", "the", "internal", "vocabulary", "and", "computes", "various", "statistics", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L207-L239
train
jfilter/text-classification-keras
texcla/preprocessing/tokenizer.py
Tokenizer.pad_sequences
def pad_sequences(self, sequences, fixed_sentences_seq_length=None, fixed_token_seq_length=None, padding='pre', truncating='post', padding_token="<PAD>"): """Pads each sequence to the same fixed length (length of the longest sequence or provided override). Args: sequen...
python
def pad_sequences(self, sequences, fixed_sentences_seq_length=None, fixed_token_seq_length=None, padding='pre', truncating='post', padding_token="<PAD>"): """Pads each sequence to the same fixed length (length of the longest sequence or provided override). Args: sequen...
[ "def", "pad_sequences", "(", "self", ",", "sequences", ",", "fixed_sentences_seq_length", "=", "None", ",", "fixed_token_seq_length", "=", "None", ",", "padding", "=", "'pre'", ",", "truncating", "=", "'post'", ",", "padding_token", "=", "\"<PAD>\"", ")", ":", ...
Pads each sequence to the same fixed length (length of the longest sequence or provided override). Args: sequences: list of list (samples, words) or list of list of list (samples, sentences, words) fixed_sentences_seq_length: The fix sentence sequence length to use. If None, largest sen...
[ "Pads", "each", "sequence", "to", "the", "same", "fixed", "length", "(", "length", "of", "the", "longest", "sequence", "or", "provided", "override", ")", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L241-L271
train
jfilter/text-classification-keras
texcla/preprocessing/tokenizer.py
Tokenizer.get_stats
def get_stats(self, i): """Gets the standard statistics for aux_index `i`. For example, if `token_generator` generates `(text_idx, sentence_idx, word)`, then `get_stats(0)` will return various statistics about sentence lengths across texts. Similarly, `get_counts(1)` will return statistics of to...
python
def get_stats(self, i): """Gets the standard statistics for aux_index `i`. For example, if `token_generator` generates `(text_idx, sentence_idx, word)`, then `get_stats(0)` will return various statistics about sentence lengths across texts. Similarly, `get_counts(1)` will return statistics of to...
[ "def", "get_stats", "(", "self", ",", "i", ")", ":", "# OrderedDict to always show same order if printed.", "result", "=", "OrderedDict", "(", ")", "result", "[", "'min'", "]", "=", "np", ".", "min", "(", "self", ".", "_counts", "[", "i", "]", ")", "result...
Gets the standard statistics for aux_index `i`. For example, if `token_generator` generates `(text_idx, sentence_idx, word)`, then `get_stats(0)` will return various statistics about sentence lengths across texts. Similarly, `get_counts(1)` will return statistics of token lengths across sentences. ...
[ "Gets", "the", "standard", "statistics", "for", "aux_index", "i", ".", "For", "example", "if", "token_generator", "generates", "(", "text_idx", "sentence_idx", "word", ")", "then", "get_stats", "(", "0", ")", "will", "return", "various", "statistics", "about", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L286-L299
train
jfilter/text-classification-keras
texcla/embeddings.py
build_embedding_weights
def build_embedding_weights(word_index, embeddings_index): """Builds an embedding matrix for all words in vocab using embeddings_index """ logger.info('Loading embeddings for all words in the corpus') embedding_dim = list(embeddings_index.values())[0].shape[-1] # setting special tokens such as UNK ...
python
def build_embedding_weights(word_index, embeddings_index): """Builds an embedding matrix for all words in vocab using embeddings_index """ logger.info('Loading embeddings for all words in the corpus') embedding_dim = list(embeddings_index.values())[0].shape[-1] # setting special tokens such as UNK ...
[ "def", "build_embedding_weights", "(", "word_index", ",", "embeddings_index", ")", ":", "logger", ".", "info", "(", "'Loading embeddings for all words in the corpus'", ")", "embedding_dim", "=", "list", "(", "embeddings_index", ".", "values", "(", ")", ")", "[", "0"...
Builds an embedding matrix for all words in vocab using embeddings_index
[ "Builds", "an", "embedding", "matrix", "for", "all", "words", "in", "vocab", "using", "embeddings_index" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L146-L161
train
jfilter/text-classification-keras
texcla/embeddings.py
build_fasttext_wiki_embedding_obj
def build_fasttext_wiki_embedding_obj(embedding_type): """FastText pre-trained word vectors for 294 languages, with 300 dimensions, trained on Wikipedia. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. It's implemented as 'FasttextWikiTokenizer'. More information:...
python
def build_fasttext_wiki_embedding_obj(embedding_type): """FastText pre-trained word vectors for 294 languages, with 300 dimensions, trained on Wikipedia. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. It's implemented as 'FasttextWikiTokenizer'. More information:...
[ "def", "build_fasttext_wiki_embedding_obj", "(", "embedding_type", ")", ":", "lang", "=", "embedding_type", ".", "split", "(", "'.'", ")", "[", "2", "]", "return", "{", "'file'", ":", "'wiki.{}.vec'", ".", "format", "(", "lang", ")", ",", "'url'", ":", "'h...
FastText pre-trained word vectors for 294 languages, with 300 dimensions, trained on Wikipedia. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. It's implemented as 'FasttextWikiTokenizer'. More information: https://fasttext.cc/docs/en/pretrained-vectors.html. Arg...
[ "FastText", "pre", "-", "trained", "word", "vectors", "for", "294", "languages", "with", "300", "dimensions", "trained", "on", "Wikipedia", ".", "It", "s", "recommended", "to", "use", "the", "same", "tokenizer", "for", "your", "data", "that", "was", "used", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L164-L177
train
jfilter/text-classification-keras
texcla/embeddings.py
build_fasttext_cc_embedding_obj
def build_fasttext_cc_embedding_obj(embedding_type): """FastText pre-trained word vectors for 157 languages, with 300 dimensions, trained on Common Crawl and Wikipedia. Released in 2018, it succeesed the 2017 FastText Wikipedia embeddings. It's recommended to use the same tokenizer for your data that was used to co...
python
def build_fasttext_cc_embedding_obj(embedding_type): """FastText pre-trained word vectors for 157 languages, with 300 dimensions, trained on Common Crawl and Wikipedia. Released in 2018, it succeesed the 2017 FastText Wikipedia embeddings. It's recommended to use the same tokenizer for your data that was used to co...
[ "def", "build_fasttext_cc_embedding_obj", "(", "embedding_type", ")", ":", "lang", "=", "embedding_type", ".", "split", "(", "'.'", ")", "[", "2", "]", "return", "{", "'file'", ":", "'cc.{}.300.vec.gz'", ".", "format", "(", "lang", ")", ",", "'url'", ":", ...
FastText pre-trained word vectors for 157 languages, with 300 dimensions, trained on Common Crawl and Wikipedia. Released in 2018, it succeesed the 2017 FastText Wikipedia embeddings. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. This information and more can be fin...
[ "FastText", "pre", "-", "trained", "word", "vectors", "for", "157", "languages", "with", "300", "dimensions", "trained", "on", "Common", "Crawl", "and", "Wikipedia", ".", "Released", "in", "2018", "it", "succeesed", "the", "2017", "FastText", "Wikipedia", "emb...
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L180-L193
train
jfilter/text-classification-keras
texcla/embeddings.py
get_embeddings_index
def get_embeddings_index(embedding_type='glove.42B.300d', embedding_dims=None, embedding_path=None, cache=True): """Retrieves embeddings index from embedding name or path. Will automatically download and cache as needed. Args: embedding_type: The embedding type to load. embedding_path: Path to ...
python
def get_embeddings_index(embedding_type='glove.42B.300d', embedding_dims=None, embedding_path=None, cache=True): """Retrieves embeddings index from embedding name or path. Will automatically download and cache as needed. Args: embedding_type: The embedding type to load. embedding_path: Path to ...
[ "def", "get_embeddings_index", "(", "embedding_type", "=", "'glove.42B.300d'", ",", "embedding_dims", "=", "None", ",", "embedding_path", "=", "None", ",", "cache", "=", "True", ")", ":", "if", "embedding_path", "is", "not", "None", ":", "embedding_type", "=", ...
Retrieves embeddings index from embedding name or path. Will automatically download and cache as needed. Args: embedding_type: The embedding type to load. embedding_path: Path to a local embedding to use instead of the embedding type. Ignores `embedding_type` if specified. Returns: The...
[ "Retrieves", "embeddings", "index", "from", "embedding", "name", "or", "path", ".", "Will", "automatically", "download", "and", "cache", "as", "needed", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L211-L257
train
jfilter/text-classification-keras
texcla/preprocessing/char_tokenizer.py
CharTokenizer.token_generator
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, character)` """ for text_idx, text in enumerate(texts): if self.lower: text = text.lower() for char in text: yield text_idx, char
python
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, character)` """ for text_idx, text in enumerate(texts): if self.lower: text = text.lower() for char in text: yield text_idx, char
[ "def", "token_generator", "(", "self", ",", "texts", ",", "*", "*", "kwargs", ")", ":", "for", "text_idx", ",", "text", "in", "enumerate", "(", "texts", ")", ":", "if", "self", ".", "lower", ":", "text", "=", "text", ".", "lower", "(", ")", "for", ...
Yields tokens from texts as `(text_idx, character)`
[ "Yields", "tokens", "from", "texts", "as", "(", "text_idx", "character", ")" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/char_tokenizer.py#L27-L34
train
jfilter/text-classification-keras
texcla/preprocessing/char_tokenizer.py
SentenceCharTokenizer.token_generator
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, sent_idx, character)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. ...
python
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, sent_idx, character)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. ...
[ "def", "token_generator", "(", "self", ",", "texts", ",", "*", "*", "kwargs", ")", ":", "# Perf optimization. Only process what is necessary.", "n_threads", ",", "batch_size", "=", "utils", ".", "_parse_spacy_kwargs", "(", "*", "*", "kwargs", ")", "nlp", "=", "s...
Yields tokens from texts as `(text_idx, sent_idx, character)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate in...
[ "Yields", "tokens", "from", "texts", "as", "(", "text_idx", "sent_idx", "character", ")" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/char_tokenizer.py#L53-L80
train
jfilter/text-classification-keras
texcla/utils/sampling.py
equal_distribution_folds
def equal_distribution_folds(y, folds=2): """Creates `folds` number of indices that has roughly balanced multi-label distribution. Args: y: The multi-label outputs. folds: The number of folds to create. Returns: `folds` number of indices that have roughly equal multi-label distribu...
python
def equal_distribution_folds(y, folds=2): """Creates `folds` number of indices that has roughly balanced multi-label distribution. Args: y: The multi-label outputs. folds: The number of folds to create. Returns: `folds` number of indices that have roughly equal multi-label distribu...
[ "def", "equal_distribution_folds", "(", "y", ",", "folds", "=", "2", ")", ":", "n", ",", "classes", "=", "y", ".", "shape", "# Compute sample distribution over classes", "dist", "=", "y", ".", "sum", "(", "axis", "=", "0", ")", ".", "astype", "(", "'floa...
Creates `folds` number of indices that has roughly balanced multi-label distribution. Args: y: The multi-label outputs. folds: The number of folds to create. Returns: `folds` number of indices that have roughly equal multi-label distributions.
[ "Creates", "folds", "number", "of", "indices", "that", "has", "roughly", "balanced", "multi", "-", "label", "distribution", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/utils/sampling.py#L11-L44
train
jfilter/text-classification-keras
texcla/models/sentence_model.py
SentenceModelFactory.build_model
def build_model(self, token_encoder_model, sentence_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model that first encodes all words within sentences using `token_encoder_model`, followed by `sentence_encoder_model`. Args: to...
python
def build_model(self, token_encoder_model, sentence_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model that first encodes all words within sentences using `token_encoder_model`, followed by `sentence_encoder_model`. Args: to...
[ "def", "build_model", "(", "self", ",", "token_encoder_model", ",", "sentence_encoder_model", ",", "trainable_embeddings", "=", "True", ",", "output_activation", "=", "'softmax'", ")", ":", "if", "not", "isinstance", "(", "token_encoder_model", ",", "SequenceEncoderBa...
Builds a model that first encodes all words within sentences using `token_encoder_model`, followed by `sentence_encoder_model`. Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding tokens within sentences. This model will be applied across all sentenc...
[ "Builds", "a", "model", "that", "first", "encodes", "all", "words", "within", "sentences", "using", "token_encoder_model", "followed", "by", "sentence_encoder_model", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/models/sentence_model.py#L45-L104
train
jfilter/text-classification-keras
texcla/experiment.py
process_save
def process_save(X, y, tokenizer, proc_data_path, max_len=400, train=False, ngrams=None, limit_top_tokens=None): """Process text and save as Dataset """ if train and limit_top_tokens is not None: tokenizer.apply_encoding_options(limit_top_tokens=limit_top_tokens) X_encoded = tokenizer.encode_te...
python
def process_save(X, y, tokenizer, proc_data_path, max_len=400, train=False, ngrams=None, limit_top_tokens=None): """Process text and save as Dataset """ if train and limit_top_tokens is not None: tokenizer.apply_encoding_options(limit_top_tokens=limit_top_tokens) X_encoded = tokenizer.encode_te...
[ "def", "process_save", "(", "X", ",", "y", ",", "tokenizer", ",", "proc_data_path", ",", "max_len", "=", "400", ",", "train", "=", "False", ",", "ngrams", "=", "None", ",", "limit_top_tokens", "=", "None", ")", ":", "if", "train", "and", "limit_top_token...
Process text and save as Dataset
[ "Process", "text", "and", "save", "as", "Dataset" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L106-L126
train
jfilter/text-classification-keras
texcla/experiment.py
setup_data
def setup_data(X, y, tokenizer, proc_data_path, **kwargs): """Setup data Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_path: Path for the processed data """ # only build vocabulary once (e.g. training data) train = ...
python
def setup_data(X, y, tokenizer, proc_data_path, **kwargs): """Setup data Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_path: Path for the processed data """ # only build vocabulary once (e.g. training data) train = ...
[ "def", "setup_data", "(", "X", ",", "y", ",", "tokenizer", ",", "proc_data_path", ",", "*", "*", "kwargs", ")", ":", "# only build vocabulary once (e.g. training data)", "train", "=", "not", "tokenizer", ".", "has_vocab", "if", "train", ":", "tokenizer", ".", ...
Setup data Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_path: Path for the processed data
[ "Setup", "data" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L129-L145
train
jfilter/text-classification-keras
texcla/experiment.py
split_data
def split_data(X, y, ratio=(0.8, 0.1, 0.1)): """Splits data into a training, validation, and test set. Args: X: text data y: data labels ratio: the ratio for splitting. Default: (0.8, 0.1, 0.1) Returns: split data: X_train, X_val, X_test, y_train, y_...
python
def split_data(X, y, ratio=(0.8, 0.1, 0.1)): """Splits data into a training, validation, and test set. Args: X: text data y: data labels ratio: the ratio for splitting. Default: (0.8, 0.1, 0.1) Returns: split data: X_train, X_val, X_test, y_train, y_...
[ "def", "split_data", "(", "X", ",", "y", ",", "ratio", "=", "(", "0.8", ",", "0.1", ",", "0.1", ")", ")", ":", "assert", "(", "sum", "(", "ratio", ")", "==", "1", "and", "len", "(", "ratio", ")", "==", "3", ")", "X_train", ",", "X_rest", ",",...
Splits data into a training, validation, and test set. Args: X: text data y: data labels ratio: the ratio for splitting. Default: (0.8, 0.1, 0.1) Returns: split data: X_train, X_val, X_test, y_train, y_val, y_test
[ "Splits", "data", "into", "a", "training", "validation", "and", "test", "set", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L148-L164
train
jfilter/text-classification-keras
texcla/experiment.py
setup_data_split
def setup_data_split(X, y, tokenizer, proc_data_dir, **kwargs): """Setup data while splitting into a training, validation, and test set. Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_dir: Directory for the split and processed d...
python
def setup_data_split(X, y, tokenizer, proc_data_dir, **kwargs): """Setup data while splitting into a training, validation, and test set. Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_dir: Directory for the split and processed d...
[ "def", "setup_data_split", "(", "X", ",", "y", ",", "tokenizer", ",", "proc_data_dir", ",", "*", "*", "kwargs", ")", ":", "X_train", ",", "X_val", ",", "X_test", ",", "y_train", ",", "y_val", ",", "y_test", "=", "split_data", "(", "X", ",", "y", ")",...
Setup data while splitting into a training, validation, and test set. Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_dir: Directory for the split and processed data
[ "Setup", "data", "while", "splitting", "into", "a", "training", "validation", "and", "test", "set", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L167-L186
train
jfilter/text-classification-keras
texcla/experiment.py
load_data_split
def load_data_split(proc_data_dir): """Loads a split dataset Args: proc_data_dir: Directory with the split and processed data Returns: (Training Data, Validation Data, Test Data) """ ds_train = Dataset.load(path.join(proc_data_dir, 'train.bin')) ds_val = Dataset...
python
def load_data_split(proc_data_dir): """Loads a split dataset Args: proc_data_dir: Directory with the split and processed data Returns: (Training Data, Validation Data, Test Data) """ ds_train = Dataset.load(path.join(proc_data_dir, 'train.bin')) ds_val = Dataset...
[ "def", "load_data_split", "(", "proc_data_dir", ")", ":", "ds_train", "=", "Dataset", ".", "load", "(", "path", ".", "join", "(", "proc_data_dir", ",", "'train.bin'", ")", ")", "ds_val", "=", "Dataset", ".", "load", "(", "path", ".", "join", "(", "proc_d...
Loads a split dataset Args: proc_data_dir: Directory with the split and processed data Returns: (Training Data, Validation Data, Test Data)
[ "Loads", "a", "split", "dataset" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L189-L201
train
jfilter/text-classification-keras
texcla/models/token_model.py
TokenModelFactory.build_model
def build_model(self, token_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model using the given `text_model` Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding all the tokens within a document. This encoding is ...
python
def build_model(self, token_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model using the given `text_model` Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding all the tokens within a document. This encoding is ...
[ "def", "build_model", "(", "self", ",", "token_encoder_model", ",", "trainable_embeddings", "=", "True", ",", "output_activation", "=", "'softmax'", ")", ":", "if", "not", "isinstance", "(", "token_encoder_model", ",", "SequenceEncoderBase", ")", ":", "raise", "Va...
Builds a model using the given `text_model` Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding all the tokens within a document. This encoding is then fed into a final `Dense` layer for classification. trainable_embeddings: Whether or not to fin...
[ "Builds", "a", "model", "using", "the", "given", "text_model" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/models/token_model.py#L39-L83
train
jfilter/text-classification-keras
texcla/models/layers.py
_softmax
def _softmax(x, dim): """Computes softmax along a specified dim. Keras currently lacks this feature. """ if K.backend() == 'tensorflow': import tensorflow as tf return tf.nn.softmax(x, dim) elif K.backend() is 'cntk': import cntk return cntk.softmax(x, dim) elif K.ba...
python
def _softmax(x, dim): """Computes softmax along a specified dim. Keras currently lacks this feature. """ if K.backend() == 'tensorflow': import tensorflow as tf return tf.nn.softmax(x, dim) elif K.backend() is 'cntk': import cntk return cntk.softmax(x, dim) elif K.ba...
[ "def", "_softmax", "(", "x", ",", "dim", ")", ":", "if", "K", ".", "backend", "(", ")", "==", "'tensorflow'", ":", "import", "tensorflow", "as", "tf", "return", "tf", ".", "nn", ".", "softmax", "(", "x", ",", "dim", ")", "elif", "K", ".", "backen...
Computes softmax along a specified dim. Keras currently lacks this feature.
[ "Computes", "softmax", "along", "a", "specified", "dim", ".", "Keras", "currently", "lacks", "this", "feature", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/models/layers.py#L10-L33
train