Utilspy Packages¶
utilspy.utils¶
-
utilspy.utils.
clean_str
(string)[source]¶ Tokenization/string cleaning for all datasets except for SST. Original taken from https://github.com/yoonkim/CNN_sentence/blob/master/process_data.py
- Args:
- string:
str
- string of sentences
- string:
- Returns:
- Lowercase cleaned string:
str
-
utilspy.utils.
download_file
(url, save_dir='tmp/', filename=None)[source]¶ download and save the file
- Args:
- url:
str
- url of file
- save_dir:
str
- directory to save
- filename:
str
- Name of file to save as
- url:
-
utilspy.utils.
download_files
(urls, save_dir='tmp/')[source]¶ download all files from urls
- Args:
- urls:
list
- urls of file
- save_dir:
str
- directory to save
- urls:
-
utilspy.utils.
format_filename
(s)[source]¶ Take a string and return a valid filename constructed from the string. Uses a whitelist approach: any characters not present in valid_chars are removed. Also spaces are replaced with underscores.
- Args:
- s:
str
- string
- s:
- Returns:
- Valid filename :
str
-
utilspy.utils.
logger
(logger_name='utilspy.utils', filename='log.log', level=10)[source]¶ logger for logging
- Args:
- logger_name:
str
- name of logger
- filename:
str
- path and file name
- level:
str
- logging level
- logger_name:
- Return:
- logger funcation for logging:
logger
-
utilspy.utils.
page_soup
(url)[source]¶ Make BeautifulSoup of page
- Args:
- url:
str
- url of page
- url:
- Returns:
- BeautifulSoup of page:
soup
-
utilspy.utils.
read_config
(filename)[source]¶ Parse config yaml file
- Args:
- filename:
str
- path of config file
- filename:
utilspy.decorator¶
-
utilspy.decorator.
profile
(fnc)[source]¶ A decorator that uses cProfile to profile a function And print the result
utilspy.log¶
Logger function that print time required in each session of logger
utilspy.files¶
-
utilspy.files.
delete_dirs
(folder_names)[source]¶ delete folder and all its contents
- Args: `
- folder_names:str` or
list
- string or list of folders
- folder_names:str` or
-
utilspy.files.
make_dirs
(folder_names)[source]¶ make folder if it doesnot exist
- Args:
- folder_names:
str
orlist
- string or list of folders
- folder_names:
-
utilspy.files.
move_file
(filename, out_dir)[source]¶ move file/dir
- Args:
- filename:
str
- filename of file to be moved or name of dir to be moved
- out_dir:
str
- output directory
- filename:
-
utilspy.files.
parse_path
(path, fn_only=False, ext=False, al=True)[source]¶ get the directory from filename,
- Args:
- path:
str
- path of file
- fn_only:
bol
- get the file name only from path
- ext:
bol
- split file name into name and extension
- al:
bol
- get list of dir and file name
- path:
- Returns:
- list of value:
list